cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject RE: [RT] Checked exceptions considered harmful
Date Wed, 14 Apr 2004 16:28:48 GMT


> From: news [mailto:news@sea.gmane.org] On Behalf Of Berin Loritsch
>
> > For example, Hejlsberg lists as one bad thing about rethrowing 
> > exceptions that you loose the stack trace. But if the Exception is 
> > supposed to be handled, then who cares about the stack trace?
> 
> If you rethrow the exact same exception, shouldn't the stack 
> trace remain in tact?  If you throw a wrapped exception, then 
> you can still get to the original stack trace.  The stack 
> trace is important to developers because it helps pinpoint 
> the exact place where the problem occurred.

Hejlsberg meant the case where an Exception is re-thrown and
not wrapped.

> As soon as you declare it, the compiler will require a 
> try/catch or throws clause--even if it is a RuntimeException.

No.

public class Hack {
    
    public void method () {
        method2 ();
    }
    
    public void method2 () throws IllegalArgumentException {
        throw new IllegalArgumentException ("Yadda");
    }
    
    public static void main (String[] args) {
        Hack h = new Hack ();
        h.method();
    }
}

/LS


Mime
View raw message