Added support for proper error messages