Timeline for Is ok to throw exception in normal code path which eliminate a possible programmer error?
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 4, 2014 at 3:30 | comment | added | Bryan Chen | so you basically saying if throw exception is not required, don't throw exception | |
May 4, 2014 at 3:15 | comment | added | jordan | If you are using the exception just as flow control (i.e. where an "if" would work instead), then I don't think it should be used (similar idea to the links that MichaelT provided). Exceptions, I believe, should only be used when "a function cannot do what it is supposed to do (i.e. due to invalid state or arguments, or an unacceptable response from a dependency is returned) and returning a value will be misleading". If you can work around the problem by first checking whatever precondition is failing, i.e. with an "if" statement, then I believe that should be done instead. | |
May 4, 2014 at 3:10 | comment | added | Bryan Chen | I don't understand your answer. How does it apply to my specific case? | |
May 4, 2014 at 3:09 | history | edited | jordan | CC BY-SA 3.0 |
added 16 characters in body
|
May 4, 2014 at 3:04 | history | answered | jordan | CC BY-SA 3.0 |