add support for handling errors from the api