Handle errors from api