Yet they routinely are, or they are "handled" using a top-level catch that allows for no meaningful action and is little better than throwing the exception to the user.
Error codes are typically integers.
There's no reason why an error can't be an object.
Exceptions free-up the return of functions for useful results.
The practice I currently favor is to represent errors as objects of the same type the function returns, objects that represent something meaningful about the error. Of course this isn't always possible and in any case requires good design. There are a lot of advantages to it, though.
Pretty much any negative practice regarding exceptions apply equally to error codes.
Except the one big problem with exceptions, which is the transfer of control out of context.
Yet they routinely are, or they are "handled" using a top-level catch that allows for no meaningful action and is little better than throwing the exception to the user.
Error codes are typically integers.
There's no reason why an error can't be an object.
Exceptions free-up the return of functions for useful results.
The practice I currently favor is to represent errors as objects of the same type the function returns, objects that represent something meaningful about the error. Of course this isn't always possible and in any case requires good design. There are a lot of advantages to it, though.
Pretty much any negative practice regarding exceptions apply equally to error codes.
Except the one big problem with exceptions, which is the transfer of control out of context.