commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lowe <mel...@gmail.com>
Subject Re: DO NOT REPLY [Bug 32094] - [email] All exceptions seem to be thrown as messagingExceptions
Date Mon, 15 Nov 2004 10:16:02 GMT
I guess thats why sun throw unsupported charset and address exceptions. 

As you know, i dont mind passing either back (as long as the
setCharset() throws . On the rare occasions when the user enters a
unsupported charset then bubbling the exception up would seem the
thing to do.

In both cases the exception thrown would have some semantic value. I
can help thinking that the folk who developed javamail would have been
where we are now.

A generic EmailException I think would cloud this issue. Like throwing
Messaging exception does.

One alternative is to just use the InternetAddress(String, String)
rather than the one inclusive of charset. I need to check if it would
default to the mail or the system however.

Mark

On Mon, 15 Nov 2004 18:00:43 +0800, Corey Scott <corey.scott@gmail.com> wrote:
> I like the intent, but I am not sure that it will work as we intend.
> Having the charset checked when it is set is a definate must, but it
> doesnt mean that the supplied values are of the same charset.  Eg. you
> can setCharset to US_ASCI and then supply a chinese name to the name
> property of an address.  Unless we are going to validate that the
> supplied inputs are the same as the set charset (or auto-convert
> them), this exception will still be thrown.
> 
> All that said, my preferences are for checking the setCharset (as Mark
> proposed) and NOT suppressing the exceptions in the other functions.
> 
> -Corey  
> 
> 
> 
> 
> On Mon, 15 Nov 2004 09:37:51 -0000, Eric Pugh <epugh@upstate.com> wrote:
> > It seems like having a default charset, and being able to override it is the
> > way to go.  After all, we are aiming to provide a convenience layer.  Most
> > developers don't have to deal with the charset at all...
> >
> >
> >
> > > -----Original Message-----
> > > From: Mark Lowe [mailto:melowe@gmail.com]
> > > Sent: Monday, November 15, 2004 8:45 AM
> > > To: Corey Scott
> > > Cc: Jakarta Commons Developers List
> > > Subject: Re: DO NOT REPLY [Bug 32094] - [email] All exceptions seem to
> > > be thrown as messagingExceptions
> > >
> > >
> > > Opps.. I'd need to watch teh null pointer exception also :o)
> > >
> > >
> > > On Mon, 15 Nov 2004 09:43:29 +0100, Mark Lowe <melowe@gmail.com> wrote:
> > > > I'm not sure what this class is for but it can be used to check
> > > char sets
> > > >
> > > > java.nio.charset.Charset
> > > >
> > > >     public void setCharset(String newCharset)
> > > >         throws UnsupportedEncodingException
> > > >     {
> > > >         if (Charset.isSupported(newCharset))
> > > >         {
> > > >             this.charset = newCharset;
> > > >         }
> > > >         else
> > > >         {
> > > >             throw new UnsupportedEncodingException("Charset unknown");
> > > >         }
> > > >     }
> > > >
> > > > This would mean that although we'd still need to catch the UEE is
> > > > would never have any real likelyhood of getting thown.
> > > >
> > > > If we chose a default charset we can also shorten the address creation
> > > > to something like
> > > >
> > > > private InternetAddress createAddress(String name, String email)
> > > >         throws AddressException
> > > >     {
> > > >
> > > >         InternetAddress address = null;
> > > > try
> > > > new InternetAddress(email, name, this.charset);
> > > > } catch(UEE e) {
> > > >
> > > > }
> > > >         address.validate();
> > > >         return address;
> > > >     }
> > > >
> > > > Would be okay wouldn't it?
> > > >
> > > > Mark
> > > >
> > > >
> > > >
> > > > On Mon, 15 Nov 2004 14:17:57 +0800, Corey Scott
> > > <corey.scott@gmail.com> wrote:
> > > > > I also like these ideas and am happy to help you implement them if
you
> > > > > would like.  However there is one thing we may want to be aware of.
 I
> > > > > dont think that the setCharset causes the UnsupportedCharsetException
> > > > > to be throw, I believe that it doesn't check it and therefore allows
> > > > > for any value to be set.  As we are trying to keep email small and
> > > > > maintainable, I dont think it is a good idea to try to added
> > > > > verfication to our classes.  That said, I believe that the only value
> > > > > I came accross during testing that did throw this exception was the
> > > > > setName part of the addresses.  Therefore the unsupported charset
> > > > > exception is thrown for all of the setFrom, addTo, addCc, addBcc,
etc
> > > > > functions only at the moment.
> > > > >
> > > > > I hope this helps,
> > > > > Corey
> > > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
>

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


Mime
View raw message