> >Returning error result more than one level is an anti-pattern. It means that you really need exceptions in this case, since you're starting to emulate them.
> Or maybe exceptions are the anti-pattern, and returning error codes is a more structured—i.e. refactorable—way of coping with such conditions.
Well implemented exception systems allow you to transparently handle exceptions up in the stack, not only in the local context that generated them. Instead, if you want to pass up error codes, you will have to manually make sure that every error code is passed as the error code of the current routine and the flow is stopped as soon as an error is detected.
Using error codes also makes it difficult to generate clear and details backtraces, unless your error-reporting routines have a way to write down where the error originally happened and how it has been propagated up in the stack. If you have such facilities then you have implemented an exception systems.