Source code for gerrit.utils.exceptions

"""Module for custom exceptions.

Where possible we try to throw exceptions with non-generic,
meaningful names.
"""


[docs] class GerritAPIException(Exception): """ Base class for all errors """
[docs] class ClientError(GerritAPIException): """ ClientError """
[docs] class ServerError(GerritAPIException): """ ServerError """
[docs] class UnauthorizedError(GerritAPIException): """ 401 Unauthorized """
[docs] class AuthError(ClientError): """ 403 Forbidden is returned if the operation is not allowed because the calling user does not have sufficient permissions. """
[docs] class ValidationError(ClientError): """ 400 Bad Request is returned if the request is not understood by the server due to malformed syntax. E.g. 400 Bad Request is returned if JSON input is expected but the 'Content-Type' of the request is not 'application/json' or the request body doesn't contain valid JSON. 400 Bad Request is also returned if required input fields are not set or if options are set which cannot be used together. """
[docs] class NotAllowedError(ClientError): """ 405 Method Not Allowed is returned if the resource exists but doesn't support the operation. """
[docs] class ConflictError(ClientError): """ 409 Conflict is returned if the request cannot be completed because the current state of the resource doesn't allow the operation. """
[docs] class NotFoundError(ClientError): """ Resource cannot be found """
[docs] class UnknownBranch(KeyError, NotFoundError): """ Gerrit does not recognize the branch requested. """
[docs] class UnknownTag(KeyError, NotFoundError): """ Gerrit does not recognize the tag requested. """
[docs] class UnknownFile(KeyError, NotFoundError): """ Gerrit does not recognize the revision file requested. """