Timeline for Are there legitimate reasons for returning exception objects instead of throwing them?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 18, 2018 at 12:14 | comment | added | Frayt | @cgTag Your use of inline code blocks for italics makes my brain hurt.. | |
| S Oct 18, 2013 at 20:19 | history | suggested | samthebrand | CC BY-SA 3.0 | This answer will be featured at Ars Technica! Edited a few statements for clarity. Please @ me in chat if you think I've changed the meaning of the response. Thx! |
| Oct 18, 2013 at 20:14 | review | Suggested edits | |||
| S Oct 18, 2013 at 20:19 | |||||
| Aug 5, 2013 at 22:27 | comment | added | Reactgular | @stakx programmers have and will continue to do things that are confusing to other programmers, but not technically incorrect. That's why I said it was semantics. The legal answer is No you are not breaking any contracts. The popular opinion would be that you shouldn't do that. Programming is full of examples where your source code does nothing wrong but everyone dislikes it. Source code should always be written so that it's clear what the intent is. Are you really helping another programmer by using an exception that way? If yes, then do so. Otherwise don't be surprised if it's disliked. | |
| Aug 5, 2013 at 22:17 | vote | accept | stakx | ||
| Aug 5, 2013 at 21:09 | comment | added | stakx | "If it is never thrown then it's not an exception. It is an object derived from an Exception class but does not follow the behavior." -- And that is exactly the issue: Is it legitimate to use an Exception-derived object in a situation where it won't get thrown at all, neither by the producer of the object, nor by any calling method; where it only serves as a "state message" being passed around, without the "super return" control flow? Or am I violating an unspoken try/catch(Exception) contract so badly that I should never do this, and instead use a separate, non-Exception type? | |
| Aug 5, 2013 at 15:06 | history | answered | Reactgular | CC BY-SA 3.0 |