You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2020/04/01 06:21:00 UTC

[jira] [Updated] (PDFBOX-4803) XMPSchema#getUnqualifiedArrayList throws a different exception

     [ https://issues.apache.org/jira/browse/PDFBOX-4803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tilman Hausherr updated PDFBOX-4803:
------------------------------------
    Component/s: XmpBox

> XMPSchema#getUnqualifiedArrayList throws a different exception
> --------------------------------------------------------------
>
>                 Key: PDFBOX-4803
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4803
>             Project: PDFBox
>          Issue Type: Bug
>          Components: XmpBox
>            Reporter: Hao Zhong
>            Priority: Major
>             Fix For: 3.0.0 PDFBox
>
>
> 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org