Return Code and Exception Summary
Exception Return Code
Pros
• Cannot be ignored
• Work well with object-oriented semantic
• Information: Exceptions can be arbitrarily rich
• Clean code: Conceptually, clean separation
between the code that detects errors and the
co d e that handles the error, but. . . *
• Non-Intrusive wrt. API: Proper communication
channel
• Visibility: prototype of the called function
• No performance overhead
• No code bloat
• Easy to debug
Cons
• Visibility: Not visible without further analysis of
the code or documentation
• Clean code: *... handling exception can generate
more code than the functionality itself
• Dynamic behavior: memory and RTTI
• Extreme performance overhead in the failure case
• Code bloat
• Non-trivial to debug
• Easy to ignore, [[deprecated]] can help
• Cannot be used with object-oriented semantic
• Information: Historically, a simple integer.
Nowadays, richer error code
• Clean code: At least, an if statement after
each function call
• Non-Intrusive wrt. API: Monopolization of
the return channel
29/56