|
OT: Bad examples everywhere (Was: distinguishing between failures and erro: msg#00134java.junit.user
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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: distinguishing between failures and errors, pholser |
|---|---|
| Next by Date: | Using exceptions (Re: distinguishing between failures and errors), J. B. Rainsberger |
| Previous by Thread: | Re: Re: distinguishing between failures and errors, Mike Clark |
| Next by Thread: | Re: OT: Bad examples everywhere (Was: distinguishing between failures and errors), Eric Heikkila |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |