what about:
catch (RuntimeException er)
{
throw new CreationException(er);
}
catch (Exception e)
{
throw new WebBeansException(er);
}
?
At least I think we must not catch java.lang.Error!
I think with 'exception' the spec really means java.lang.Exception and not all
Throwables.
We must not catch things like java.lang.OutOfMemoryError or
java.lang.ThreadDead! This should be handled by the appsrv if any.
I only know a hand full of apps who use Errors for program behaviour, and this
mostly because they are basically _not_ being catched.
LieGrü,
strub
--- Gurkan Erdogdu <[email protected]> schrieb am Mo, 12.1.2009:
> Von: Gurkan Erdogdu <[email protected]>
> Betreff: Re: Throwable catching question
> An: [email protected]
> Datum: Montag, 12. Januar 2009, 12:25
> Hi Mark;
>
> Good point :) It seems meaningless to do so.
>
> In the specification says that
> "If any exception occurs while creating the instance ,
> the exception is throws by the create() method. If the
> exception is the checked exception, it is wrapped and and
> rethrown as an (unchecked) CreationException".
>
> I suspect that I did it wrongly. we may change *Exception*
> to the *RuntimeException* as
> catch (Throwable e)
> {
> if
> (RuntimeException.class.isAssignableFrom(e.getClass()))
> {
> throw new CreationException(e);
> }
> else
> {
> throw new WebBeansException(e);
> }
> }
>
>
> /Gurkan
>
>
> ________________________________
> From: Mark Struberg <[email protected]>
> To: [email protected]
> Sent: Monday, January 12, 2009 12:33:59 PM
> Subject: Throwable catching question
>
> Hi Gurkan!
>
> I have a question about a construct I saw some times (e.g.
> in AbstracCommponent#create() ) and I frankly do not
> understand what it's good for:
>
> catch (Throwable e)
> {
> if
> (Exception.class.isAssignableFrom(e.getClass()))
> {
> throw new CreationException(e);
> }
> }
>
> So all Errors (like e.g. ThreadDead) are silently catched
> away?
> Is there any reason for this?
>
> Why not simply do a:
>
> catch (Exception e)
> {
> throw new CreationException(e);
> }
>
>
> Or did I miss something?
>
> txs and LieGrue,
> strub