Error Handling
API calls can fail when input data is malformed or the server detects issues with the request. As an example, the following request obviously fails:
When a request fails, an APIException
is thrown. Specific errors may throw a child exception of APIException
.
#
APIExceptionA very general API error. The message is parsed from the API response's JSON body and the response is available as a public property.
#
APIUnauthorizedExceptionProvides the same properties as APIException
and occurs when the access token is expired or not provided. Notice that an access token has to be included in every request. Spotify does not allow unauthorized API access.
#
APITooManyRequestsExceptionProvides the same properties as APIException
and occurs when too many requests has been sent by your application. It also provides the property TimeSpan RetryAfter
, which maps to the received Retry-After
header.