Hao Zhong created PDFBOX-4803:
---------------------------------
Summary: XMPSchema#getUnqualifiedArrayList throws a different
exception
Key: PDFBOX-4803
URL: https://issues.apache.org/jira/browse/PDFBOX-4803
Project: PDFBox
Issue Type: Bug
Reporter: Hao Zhong
When a property is illegal, most methods of pdfbox throw
IllegalArgumentException:
org.apache.xmpbox.schema.XMPSchema#getUnqualifiedTextProperty
org.apache.xmpbox.schema.XMPSchema#getDateProperty
org.apache.xmpbox.schema.XMPSchema#getBooleanProperty
org.apache.xmpbox.schema.XMPSchema#getIntegerPropertyValue
However, the following method throws a different exception:
org.apache.xmpbox.schema.XMPSchema#getUnqualifiedArrayList:
{code:java}
public List<AbstractField> getUnqualifiedArrayList(String name) throws
BadFieldValueException
{
ArrayProperty array = null;
for (AbstractField child : getAllProperties())
{
if (child.getPropertyName().equals(name))
{
if (child instanceof ArrayProperty)
{
array = (ArrayProperty) child;
break;
}
throw new BadFieldValueException("Property asked is not an
array");
}
}
if (array != null)
{
return new ArrayList<>(array.getContainer().getAllProperties());
}
return null;
}
{code}
As a result, my code fails to catch its exception. Shall the methods throw the
same exception for the same reason? For me, BadFieldValueException is even more
informative than IllegalArgumentException.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]