FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
kbengine-httpserver/httpserver/exceptions.py at master · kenny67/kbengine-httpserver · GitHub
kenny67
/
kbengine-httpserver
Public
forked from
asynchronoust/kbengine-httpserver
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
kbengine-httpserver
/
httpserver
/
exceptions.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (37 loc) · 1.07 KB
Breadcrumbs
kbengine-httpserver
/
httpserver
/
exceptions.py
Copy path
File metadata and controls
56 lines (37 loc) · 1.07 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# -*- coding: utf-8 -*-
"""
FileName: exceptions
Author: Tao Hao
@contact: taohaohust@outlook.com
Created time: 2019/5/30
Description:
Changelog:
"""
def
add_status_code
(
code
):
def
class_decorator
(
cls
):
cls
.
status_code
=
code
return
cls
return
class_decorator
class
BaseException_
(
Exception
):
def
__init__
(
self
,
message
,
status_code
=
None
):
super
(
BaseException_
,
self
).
__init__
(
message
)
self
.
status_code
=
None
if
status_code
is
not
None
:
self
.
status_code
=
status_code
@
add_status_code
(
400
)
class
InvalidUsage
(
BaseException_
):
pass
class
UriDuplicated
(
BaseException_
):
pass
@
add_status_code
(
405
)
class
MethodNotAllowed
(
BaseException_
):
def
__init__
(
self
,
method
):
msg
=
"method: %s not allowed"
%
method
super
(
MethodNotAllowed
,
self
).
__init__
(
msg
)
@
add_status_code
(
404
)
class
NotFound
(
BaseException_
):
def
__init__
(
self
,
uri
):
msg
=
"uri: %s not found"
%
uri
super
(
NotFound
,
self
).
__init__
(
msg
)
if
__name__
==
"__main__"
:
e
=
InvalidUsage
(
"test"
)
Back
|
FazBrowse Home
|
New Git URL