logo       

Re: OT: Bad examples everywhere (Was: distinguishing between failures and : msg#00136

java.junit.user

Subject: Re: OT: Bad examples everywhere (Was: distinguishing between failures and errors)

Hmm..that's one reason I've fallen in love with
Log4J. Doing something like:

catch (Exception ex) {
log.error("Something bad happened here", ex)
}

is just a nice thing to have. Your own error message
AND the exception message AND the stack trace.

-Eric

--- Mathieu Gervais <egoine_@xxxxxxxxxxx> wrote:
> From: neil_swingler
> >o Do nothing
> >o Print/log message (but not the stacktrace)
> >o Wrap the exception but lose the cause exception
> and it's stacktrace
> >o catch Exception (also catches all those
> RuntimeExceptions they had
> forgotten about
>
> ..and then you end up being the one trying to debug
> this with absolutely no
> information since they've thrown the root cause and
> the stack trace. Arghhh.
>
> I'll add one to your list :
> o Print/log message (but with neither the stacktrace
> & the exception
> classname : only the getMessage())
>
> I think this comes from the fact that most sample
> code (book examples,
> tutorial, etc..) that are read by people learning
> java include code like
> this :
>
> try {
> //something
> } catch{Exception e) {
> System.out.println("something bad happened +
> e.getMessage();
> }
>
> Then all you get is :
> "something bad happened 4"
>
> People are learning from examples and there aren't
> that many simple but good
> & completes examples out there.
>
> Every JDBC example uses string concatenation to
> build the SQL (instead of
> prepared statements) and then people wonder why the
> industry has a security
> problem with SQL injection!
>
> I just felt like saying it all! :)
>
> mathieu
>


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise