Added ability to use custom errors