Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
10280fc9
Unverified
Commit
10280fc9
authored
2 years ago
by
David Teller
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Uniformize spam-checker API, part 1: the `Code` enum. (#12703)
parent
71e8afe3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/12703.misc
+1
-0
1 addition, 0 deletions
changelog.d/12703.misc
synapse/api/errors.py
+9
-2
9 additions, 2 deletions
synapse/api/errors.py
with
10 additions
and
2 deletions
changelog.d/12703.misc
0 → 100644
+
1
−
0
View file @
10280fc9
Convert namespace class `Codes` into a string enum.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/api/errors.py
+
9
−
2
View file @
10280fc9
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
import
logging
import
logging
import
typing
import
typing
from
enum
import
Enum
from
http
import
HTTPStatus
from
http
import
HTTPStatus
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
...
@@ -30,7 +31,11 @@ if typing.TYPE_CHECKING:
...
@@ -30,7 +31,11 @@ if typing.TYPE_CHECKING:
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
Codes
:
class
Codes
(
str
,
Enum
):
"""
All known error codes, as an enum of strings.
"""
UNRECOGNIZED
=
"
M_UNRECOGNIZED
"
UNRECOGNIZED
=
"
M_UNRECOGNIZED
"
UNAUTHORIZED
=
"
M_UNAUTHORIZED
"
UNAUTHORIZED
=
"
M_UNAUTHORIZED
"
FORBIDDEN
=
"
M_FORBIDDEN
"
FORBIDDEN
=
"
M_FORBIDDEN
"
...
@@ -265,7 +270,9 @@ class UnrecognizedRequestError(SynapseError):
...
@@ -265,7 +270,9 @@ class UnrecognizedRequestError(SynapseError):
"""
An error indicating we don
'
t understand the request you
'
re trying to make
"""
"""
An error indicating we don
'
t understand the request you
'
re trying to make
"""
def
__init__
(
def
__init__
(
self
,
msg
:
str
=
"
Unrecognized request
"
,
errcode
:
str
=
Codes
.
UNRECOGNIZED
self
,
msg
:
str
=
"
Unrecognized request
"
,
errcode
:
str
=
Codes
.
UNRECOGNIZED
,
):
):
super
().
__init__
(
400
,
msg
,
errcode
)
super
().
__init__
(
400
,
msg
,
errcode
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment