feat: add models and partially custom error messages

This commit is contained in:
firedotguy
2026-01-31 12:10:20 +03:00
parent c7e3812ee8
commit a388426d8d
15 changed files with 352 additions and 71 deletions

43
itd/exceptions.py Normal file
View File

@@ -0,0 +1,43 @@
class NoCookie(Exception):
def __str__(self):
return 'No cookie for refresh-token required action'
class NoAuthData(Exception):
def __str__(self):
return 'No auth data. Provide token or cookies'
class InvalidCookie(Exception):
def __str__(self):
return f'Invalid cookie data'
class InvalidToken(Exception):
def __str__(self):
return f'Invalid access token'
class SamePassword(Exception):
def __str__(self):
return 'Old and new password must not equals'
class InvalidOldPassword(Exception):
def __str__(self):
return 'Old password is incorrect'
class UserNotFound(Exception):
def __str__(self):
return 'User not found'
class UserBanned(Exception):
def __str__(self):
return 'User banned'
class InvalidProfileData(Exception):
def __init__(self, name: str, value: str):
self.name = name
self.value = value
def __str__(self):
return f'Invalid update profile data {self.name}: "{self.value}"'
class PendingRequestExists(Exception):
def __str__(self):
return 'Pending verifiaction request already exists'