james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Burrell Donkin" <robertburrelldon...@gmail.com>
Subject Re: [mime4j] MimeException in Field.parse()
Date Sun, 09 Nov 2008 22:28:48 GMT
On Sun, Nov 9, 2008 at 9:50 PM, Markus Wiederkehr
<markus.wiederkehr@gmail.com> wrote:
> On Sun, Nov 9, 2008 at 10:35 PM, Oleg Kalnichevski <olegk@apache.org> wrote:
>> I personally prefer a subclass of Throwable to express some kind of
>> exceptional condition, but could live with InvalidField or some such.
> Mime4j does not throw an exception if a date header field is
> malformed. The same is true for erroneous address lists, mailboxes and
> mailbox lists.

the mime4j API is inconsistent. the other fields expose any exception
using a getter. i suspect that this design was adopted to allow the
caller to decide whether they wanted to ignore unparsable fields or

the consistent way to remove the throws clause would be to pull the
getter up from the subclasses. the major problem with this approach
would be to break callers relying on catch blocks which would need to
be replaced with a getter check.

> Wouldn't it be consequent not to throw an exception if a header field
> does not match the required regex?
> Another possible solution would be:
>    public static Field parseUnchecked(final String raw) throws
> IllegalArgumentException {
>        // ...
>    }
>    public static Field parse(final String raw) throws MimeException {
>        try {
>            return parseUnchecked(raw);
>        } catch (IllegalArgumentException e) {
>            throw new MimeException("Invalid header field", e);
>        }
>    }
> I'm not sure if I like that either..

i would prefer not to use a RuntimeException. a getter would be more
consistent with the rest of the API.

- robert

To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org

View raw message