"""Application exceptions.""" from switchboard_consumer.formatters.errors import format_graphql_errors class FailedToStartError(Exception): """Should be raised when application fails to start.""" def __init__(self, reason, *args, **kwargs): """Create new instance of FailedToStartError. Args: reason (str): Description of failure. """ super(FailedToStartError).__init__(*args, **kwargs) self.reason = reason def __str__(self): """Get string representation of FailedToStart error.""" return 'Application failed to start due to: {0}'.format(self.reason) class GraphQLError(Exception): """GraphQLError Exception.""" def __init__(self, message, raw_errors, *args, **kwargs): """Create new instance of GraphQLError. Args: message (str): explanation of the error raw_errors (str): GraphQL underlying error. """ super(GraphQLError).__init__(*args, **kwargs) self.message = message self.raw_errors = format_graphql_errors(raw_errors) class ParticipantHandlerGraphQLError(GraphQLError): """ParticpantHandlerGraphQLError Exception.""" pass class ParticipantHandlerError(Exception): """ParticpantHandlerError Exception.""" pass class ReleaseCorrectionError(Exception): """ReleaseCorrectionError Exception.""" pass class ProductSubmissionError(Exception): """ProductSubmissionError Exception.""" pass