Added support for API errors