Files
db-middleware/core/exceptions.py

49 lines
1.4 KiB
Python

from fastapi import HTTPException
class ObjectNotFoundInDB(Exception):
def __init__(self, *args):
super().__init__(*args)
class UserNotFound(HTTPException):
def __init__(
self,
status_code=404,
detail={
"message": "Didn't find a user with the provided id.",
"code": "user-not-found",
},
headers=None,
):
super().__init__(status_code, detail, headers)
class QueryValidationError(ValueError):
def __init__(self, loc: list[str], msg: str):
self.loc = loc
self.msg = msg
super().__init__(msg)
class QueryNotFound(HTTPException):
def __init__(self, status_code=404, detail = {
'message': "The referenced query was not found.",
"code": 'query-not-found'
}, headers = None):
super().__init__(status_code, detail, headers)
class ConnectionNotFound(HTTPException):
def __init__(self, status_code=404, detail = {
'message': "The referenced connection was not found.",
"code": 'connection-not-found'
}, headers = None):
super().__init__(status_code, detail, headers)
class PoolNotFound(HTTPException):
def __init__(self, status_code=404, detail = {
'message': "We didn't find a running Pool for the referenced connection.",
"code": 'pool-not-found'
}, headers = None):
super().__init__(status_code, detail, headers)