Exceptions

The following exceptions are thrown by the library.

exception coc.ClashOfClansException

Base exception for coc.py

exception coc.HTTPException(response=None, data=None)

Base exception for when a HTTP request fails

response

aiohttp.ClientResponse - The response of the failed HTTP request.

status

int - The status code of the HTTP request

reason
str - The reason provided by the API.

This could be an empty string if nothing was given.

message
str - The more detailed message provided by the API.

This could be an empty string if nothing was given

exception coc.InvalidArgument(response=None, data=None)

Thrown when an error status 400 occurs.

Client provided incorrect parameters for the request.

Subclass of HTTPException

exception coc.InvalidCredentials(response='Invalid Credentials')

Thrown when an error status 403 occurs and the reason is invalid credentials.

Special Exception thrown when missing/incorrect credentials were passed. This is when your email/password pair is incorrect. Subclass of HTTPException

exception coc.Forbidden(response=None, data=None)

Thrown when an error status 403 occurs.

API token does not grant access to the requested resource.

Subclass of HTTPException

exception coc.NotFound(response=None, data=None)

Thrown when an error status 404 occurs.

The resource was not found.

Subclass of HTTPException

exception coc.Maintenance(response=None, data=None)

Thrown when an error status 503 occurs.

Service is temporarily unavailable because of maintenance.

Subclass of HTTPException

exception coc.GatewayError(response=None, data=None)

Thrown when a gateway error occurs. These are either status 502 or 504

Error code 502: Bad Gateway Error code 504: The Gateway has timed-out.

Subclass of HTTPException

exception coc.PrivateWarLog(response=None, data=None)

Thrown when an error status 403 occurs when trying to get a clan’s war info.

This is a special subclass of Forbidden for when a clan’s war log is private.