Files
contest-assistant/bot/exceptions.py
Xevion 8f67b3c785 Fix MutableJSON issues with NestedMutableList
Add new exception SelfVoteException for Submission.increment
Implement new string representation built-in functions for all models
2021-02-17 02:55:55 -06:00

40 lines
1.2 KiB
Python

class ContestException(Exception):
"""A exception directly related to the Contest Assistant bot."""
pass
class FinishedPeriodException(ContestException):
"""A inactive period, or a period in it's final state cannot be advanced or further modified."""
def __repr__(self) -> str:
return 'Period is inactive.'
class DatabaseDoubleVoteException(ContestException):
"""
The database was asked to increment a vote for a submission with a user ID that was already added.
Companion to `DatabaseNoVoteException`
"""
def __repr__(self) -> str:
return 'You can\'t vote for a submission twice.'
class DatabaseNoVoteException(ContestException):
"""
The database was asked to decrement a vote for a submission with a user ID that did not or no longer exists for the given submission.
Companion to `DatabaseDoubleVoteException`
"""
def __repr__(self) -> str:
return 'You can\'t remove a vote that never or no longer exists'
class SelfVoteException(ContestException):
"""A user tried to vote on his own submission."""
def __repr__(self) -> str:
return 'You can\'t vote on your own submission. Please choose another post.'