craftbeerpi4-pione/venv/lib/python3.8/site-packages/ticket_auth/exception.py

28 lines
791 B
Python
Raw Normal View History

class TicketError(Exception):
"""Base class for errors generated by the module"""
def __init__(self, ticket, msg=''):
self.ticket = ticket
self.msg = msg
def __str__(self):
return 'Ticket error: {0} ({1})'.format(self.msg, self.ticket)
class TicketParseError(TicketError):
"""Error parsing the ticket string"""
def __init__(self, ticket, msg=''):
super().__init__(ticket, msg)
class TicketDigestError(TicketError):
"""Exception raised when a tickets digest is incorrect"""
def __init__(self, ticket):
super().__init__(ticket, 'Invalid digest')
class TicketExpired(TicketError):
"""Exception raised when a ticket has expired"""
def __init__(self, ticket):
super().__init__(ticket, 'Ticket expired')