raise a UnexpectedStatusError with status code in case of error