-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_handlers.py
59 lines (51 loc) · 1.27 KB
/
error_handlers.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
55
56
57
58
59
from flask import jsonify
class ErrorHandler:
@staticmethod
def err_not_found(e):
return jsonify({
"code" : 404,
"status" : "failed",
"message" :e,
}), 404
@staticmethod
def err_forbidden(e):
return jsonify({
"code" : 403,
"status" : "failed",
"message" :e,
}), 403
@staticmethod
def err_unprocessable_content(e):
return jsonify({
"code" : 422,
"status" : "failed",
"message" :e,
}), 422
@staticmethod
def err_internal_server_error(e):
return jsonify({
"code" : 500,
"status" : "failed",
"message" :e
}), 500
@staticmethod
def err_unauthorized(e):
return jsonify({
"code" : 401,
"status" : "failed",
"message" :e,
}), 401
@staticmethod
def err_value_error(e):
return jsonify({
"code" : 400,
"status" : "failed",
"message" :e,
}), 400
@staticmethod
def err_required_val():
return jsonify({
"code" : 400,
"status" : "failed",
"message" : "field required"
})