Exceptions: inherit from the fastapi HTTPException.
This commit is contained in:
parent
9f0430a6da
commit
1349f99cd3
@ -1,4 +1,4 @@
|
|||||||
from fastapi import status
|
from fastapi import status, HTTPException
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@ -23,11 +23,10 @@ class HttpErrorOut(BaseModel):
|
|||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
||||||
|
|
||||||
class CustomHttpException(Exception):
|
class CustomHttpException(HTTPException):
|
||||||
def __init__(self, code: str, detail: str, status_code: int = status.HTTP_400_BAD_REQUEST):
|
def __init__(self, code: str, detail: str, status_code: int = status.HTTP_400_BAD_REQUEST):
|
||||||
self.status_code = status_code
|
|
||||||
self.code = code
|
self.code = code
|
||||||
self.detail = detail
|
super().__init__(status_code, detail)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def as_dict(self) -> dict:
|
def as_dict(self) -> dict:
|
||||||
|
Loading…
Reference in New Issue
Block a user