Exceptions or return codes?(blog.tetrack.com)
blog.tetrack.com
Exceptions or return codes?
http://blog.tetrack.com/2009/01/exceptions-or-return-codes/
2 comments
This blog post fails the "well-reasoned argument" test:
Pros of Return Codes:
1) Return codes are typed
2) Return codes are cleaner than exceptions and can have additional associated data
3) Exceptions are easy to ignore
4) Return codes integrate well with third-party code (how would you use Exceptions and not blow your client's call stack?)
Error handling is hard, let's go shopping.
Pros of Return Codes:
1) Return codes are typed
2) Return codes are cleaner than exceptions and can have additional associated data
3) Exceptions are easy to ignore
4) Return codes integrate well with third-party code (how would you use Exceptions and not blow your client's call stack?)
Error handling is hard, let's go shopping.
Problems with error codes:
Too easy to ignore.
Errors and normal return codes get mixed.
Often difficult to pick a distinguished error value, 0, -1?
Problems with exceptions:
Too easy to ignore. How often do you find empty exceptions?
Too many types of exceptions, The Java libraries are particularly guilty of this.
Adding a checked exception can break code all over the universe.