-
Notifications
You must be signed in to change notification settings - Fork 6
/
exceptions.py
54 lines (50 loc) · 1.25 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Exceptions for TRS-filer."""
from connexion.exceptions import (
BadRequestProblem,
ExtraParameterProblem,
Forbidden,
Unauthorized,
)
from werkzeug.exceptions import (
BadRequest,
InternalServerError,
NotFound,
)
# exceptions raised in app context
exceptions = {
Exception: {
"message": "An unexpected error occurred.",
"code": 500,
},
BadRequestProblem: {
"message": "The request is malformed",
"code": 400,
},
BadRequest: {
"message": "The request is malformed.",
"code": 400,
},
ExtraParameterProblem: {
"message": "The request is malformed.",
"code": 400,
},
Unauthorized: {
"message": "The request is unauthorized.",
"code": 401,
},
Forbidden: {
"message": "The requester is not authorized to perform this action.",
"code": 403,
},
NotFound: {
"message": "The requested resource wasn't found.",
"code": 404,
},
InternalServerError: {
"message": "An unexpected error occurred.",
"code": 500,
}
}
# exceptions raised outside of app context
class ValidationError(Exception):
"""Value or object is not compatible with required type or schema."""