Shalini Srivastav wrote:I don't know what is the error ?
C:\slop>java Errortest
Exception in thread "main" java.lang.StackOverflowError
at Errortest.m(Errortest.java:4)
at Errortest.m(Errortest.java:4)
at Errortest.m(Errortest.java:4)
<skip about 1000 lines of this same thing over and over>
at Errortest.m(Errortest.java:4)
at Errortest.m(Errortest.java:4)
C:\slop>
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie wrote:Don’t catch Throwables or Errors in real life code
Mike Simmons wrote:Logging is good. Seeing a clear error message is good.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:(Catching a Throwable) is highly likely to make your app very slow indeed.
Logging is only of interest for debugging;
Martin Vajsar wrote:I'd be curious to know the reasoning behind this statement...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
James Boswell wrote:How about when an unexpected error occurs and the user is presented with a generic "Something unexpected happened" message (as you certainly wouldnt want them to see a stack trace).
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Martin Vajsar wrote:I'd be curious to know the reasoning behind this statement...
Because Mike's post appeared to be advocating this as a logging panacaea, which I assume to include cases when the "error" is recoverable; and throwing an Exception is, and probably always will be, very expensive.n
Mike Simmons wrote:As for the comment about propagation, I would agree that it's almost always wrong to catch a Throwable, log it, and do nothing else. Chances are good that the system is compromised...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Mike Simmons wrote:As for the comment about propagation, I would agree that it's almost always wrong to catch a Throwable, log it, and do nothing else. Chances are good that the system is compromised...
I guess your experience is different from mine then. I'm much more of a proponent of not catching Exceptions at all unless I have to; I'd far rather simply declare my method as throwing it and let some other method deal with it (hopefully the one that is supposed to) - or it not being dealt with at all.
That's the way to make sure your code is robust.
I have two major exceptions to my "rule": IllegalArgumentException and NullPointerException. Both of those should be dealt with as close to source as possible, and I totally agree with you about "clear error messages".
Martin Vajsar wrote:How do you deal with IllegalArgumentException and NullPointerException, moreover "as close to the source as possible"? Both are a result of a bug and
cannotshould not be attempted to recover from. My approach always was to let them bubble all the way up the stack into the log file and then glean from the offending line what went awry. Am I doing it wrong all the years?
Martin Vajsar wrote:How do you deal with IllegalArgumentException and NullPointerException, moreover "as close to the source as possible"? Both are a result of a bug and
cannotshould not be attempted to recover from. My approach always was to let them bubble all the way up the stack into the log file and then glean from the offending line what went awry. Am I doing it wrong all the years?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Mike Simmons wrote:Actually I agree with Martin here too. I somehow read the "deal with as close to the source as possible" as "fix the source".
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:I started off some interesting discussion there
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Mike Simmons wrote:Actually I agree with Martin here too. I somehow read the "deal with as close to the source as possible" as "fix the source".
Ah. You've clearly not worked on systems where the code is NOT under your control...or maybe you just forgot .
Dennis Deems wrote:...Let me see exactly where the null reference is encountered and what it actually is. Wrapping exceptions just adds to the pile of junk I've got to dig through to find my answer.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
4. In the case of an NPE, catch it as fast as you can; especially in cases where you know the cause.
Winston Gutkowski wrote:
5. For any situation where I'm not either (b) throwing an IllegalArgumentException,
Mike Simmons wrote:Dennis: does the framework "wrap" an exception without including the original exception as the cause?
Martin Vajsar wrote:I must admit I do sometimes code something likeand I freely admit I'm not able to glean much if the NPE happens on such a line....
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Nitish Bangera wrote:I guess the StackOverFlow problem has been masked.
Shalini Srivastav wrote:
Nitish Bangera wrote:I guess the StackOverFlow problem has been masked.
Yes,i don't know what all guys did with my post.But i had got my answer through some early posts before this all.
Junilu Lacar wrote:I'm in the camp that treats most RuntimeExceptions like IllegalArgumentException and NullPointerException as programming errors and let them be detected (ideally) while writing and running unit tests or other types of tests downstream in the development process (less ideal). If they somehow find their way to production, then you missed a test.
The moustache of a titan! The ad of a flea:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|