Added support for custom error codes