Replace Error Code with Exception
From CSSEMediaWiki
Revision as of 22:54, 14 October 2009 by Brett Ward (Talk | contribs)
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: