james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: [mime4j] MimeException in Field.parse()
Date Sun, 09 Nov 2008 19:33:26 GMT
On Sat, 2008-11-08 at 14:31 +0100, Markus Wiederkehr wrote:
> 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
> nuisance.
> 
> 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.
> 

While Field.parse() throwing a checked exception can be a nuisance, I
personally can live with that. The idea of rethrowing
IllegalArgumentException as a checked exception does not sound quite
right to me.

I will not stand in the way if someone wants to implement a different
approach, though.

Oleg

> 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
> incorrent.
> 
> 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?
> 
> Markus
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 


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


Mime
View raw message