logo       

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

java.junit.user

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

[snip...]
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.
[end snip...]

... which is just as easy to get by having the following in some utility
class:

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
return <your own message prepended to> + sw.toString();

=jason




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

News | FAQ | advertise