added support for custom Error objects