We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bef1ab8 commit e5050eeCopy full SHA for e5050ee
app/exceptions/UserException.py
@@ -1,13 +1,8 @@
1
-from fastapi import status
+from fastapi import HTTPException, status
2
3
4
-class UsersException(Exception):
5
- def __init__(self, message, status_code):
6
- self.message = message
7
- self.status_code = status_code
8
-
9
10
-class UserNotFound(UsersException):
+class UserNotFound(HTTPException):
11
def __init__(self, id: int):
12
- super().__init__(f"User with id {id} not found",
13
- status.HTTP_404_NOT_FOUND)
+ status_code = status.HTTP_404_NOT_FOUND
+ detail = f"User with id {id} not found"
+ super().__init__(status_code=status_code, detail=detail)
0 commit comments