|
|
|
|
|
by JoshuaAshton
2638 days ago
|
|
> You also can't possibly know all error codes to handle for a function if it calls other functions returning error codes You aren't using error codes or documenting correctly. You get a choice whether the error propogates upstream |
|
Example: you have a method which requests a file from disk, but it fails to load for some reason. With error codes, you force all callers of your resource loader to explicitly handle the failure case at the point of failure, or you lose all context on the error. If you just bubble the error up, you're manually doing exceptions.
With exceptions, the code that requests a file can assume it succeeds if it doesn't have enough context to handle the erorr, and you can handle at a higher level and still know what happened.