From 1349f99cd39df34df87b0a53aecf8117876fd0a2 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 4 Jan 2021 16:31:28 +0200 Subject: [PATCH] Exceptions: inherit from the fastapi HTTPException. --- etebase_fastapi/exceptions.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/etebase_fastapi/exceptions.py b/etebase_fastapi/exceptions.py index d38ef42..61e4439 100644 --- a/etebase_fastapi/exceptions.py +++ b/etebase_fastapi/exceptions.py @@ -1,4 +1,4 @@ -from fastapi import status +from fastapi import status, HTTPException import typing as t from pydantic import BaseModel @@ -23,11 +23,10 @@ class HttpErrorOut(BaseModel): orm_mode = True -class CustomHttpException(Exception): +class CustomHttpException(HTTPException): def __init__(self, code: str, detail: str, status_code: int = status.HTTP_400_BAD_REQUEST): - self.status_code = status_code self.code = code - self.detail = detail + super().__init__(status_code, detail) @property def as_dict(self) -> dict: