Added support for custom error messages