Raise exception on API request error.