fixed the setting of the error code in the error handlers