james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Markus Wiederkehr" <markus.wiederk...@gmail.com>
Subject [mime4j] MimeException in Field.parse()
Date Sat, 08 Nov 2008 13:31:51 GMT
For MIME4J-73 we changed the IllegalArgumentException in Field.parse()
to a MimeException because loading an invalid message from an
InputStream should not throw a runtime exception.

While this was correct it leads to another problem. Loading a message
from an InputStream is just one scenario. The other one is creating a
new message from scratch. If you know for certain that the header
field to parse is well-formed the MimeException is nothing but a

So maybe what we need is a checked exception for loading a message and
a runtime exception for creating a message programatically. Maybe
Field.parse() should throw an IllegalArgumentException and the code
that loads a message should convert it to a MimeException.

But there is something else. Consider parsing a message that contains
an invalid Date header field. Mime4j does _not_ throw a MimeException
in this case. Instead it returns a DateTimeField instance that
represents the invalid date. This DateTimeField also stores a
ParseException. I think the idea behind this is that it should still
be possible to parse a message even if some header fields are

In this spirit, should Field.parse() throw an exception at all? Or
would it be better to return a Field instance that represents an
invalid header field instead?

What do you think?


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

View raw message