Replace Error Code with Exception
From CSSEMediaWiki
(Difference between revisions)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Brett Ward) |
|||
(One intermediate revision by one user not shown) | |||
Line 5: | Line 5: | ||
Using exceptions seperates normal processing from error processing, making programs easier to understand. | Using exceptions seperates normal processing from error processing, making programs easier to understand. | ||
− | + | == See Also: == | |
{{refactoring}} | {{refactoring}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 03:23, 25 November 2010
If a method returns a code to indicate an error has occured ("return -1;"), it should probably be throwing an exception instead.
Martin Fowler likens using error codes to "committing suicide because you miss a flight", but does say there is merit to using error codes to stop the program if the crash is small, and the user tolerant.
Using exceptions seperates normal processing from error processing, making programs easier to understand.
See Also: