Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fastapi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roman Desyatskii
fastapi
Commits
b162c0a8
Commit
b162c0a8
authored
Jan 04, 2024
by
Roman Desyatskii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Global Errors
parent
7f594c46
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
handlers.py
src/app/exceptions/handlers.py
+30
-0
No files found.
src/app/exceptions/handlers.py
0 → 100644
View file @
b162c0a8
import
fastapi
import
pydantic
from
starlette
import
status
from
fastapi.responses
import
JSONResponse
from
app.exceptions.http
import
BaseHTTPException
async
def
query_params_exc_handler
(
request
:
fastapi
.
Request
,
exc
:
pydantic
.
ValidationError
,
)
->
JSONResponse
:
return
JSONResponse
(
{
'detail'
:
exc
.
errors
()},
status
.
HTTP_422_UNPROCESSABLE_ENTITY
,
)
async
def
request_exc_handler
(
request
:
fastapi
.
Request
,
exc
:
BaseHTTPException
,
)
->
JSONResponse
:
return
JSONResponse
(
{
'detail'
:
exc
.
detail
},
exc
.
status_code
,
)
async
def
internal_exc_handler
(
request
:
fastapi
.
Request
,
exc
:
Exception
,
)
->
JSONResponse
:
return
JSONResponse
(
{
'detail'
:
'Internal Server Error'
},
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment