summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2017-04-25 19:30:55 +0100
committerDavid Baker <dave@matrix.org>2017-04-25 19:30:55 +0100
commit1a9255c12eb73245bdbb626a1a0cad2fbe967caa (patch)
tree987da3f437c3d66ac053ab95fdd60d1b287127ca /synapse/api
parentNeed the HTTP status code (diff)
downloadsynapse-1a9255c12eb73245bdbb626a1a0cad2fbe967caa.tar.xz
Use CodeMessageException subclass instead
Parse json errors from get_json client methods and throw special
errors.
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/errors.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py

index 6fbd5d6876..d0dfa959dc 100644 --- a/synapse/api/errors.py +++ b/synapse/api/errors.py
@@ -66,6 +66,17 @@ class CodeMessageException(RuntimeError): return cs_error(self.msg) +class MatrixCodeMessageException(CodeMessageException): + """An error from a general matrix endpoint, eg. from a proxied Matrix API call. + + Attributes: + errcode (str): Matrix error code e.g 'M_FORBIDDEN' + """ + def __init__(self, code, msg, errcode=Codes.UNKNOWN): + super(MatrixCodeMessageException, self).__init__(code, msg) + self.errcode = errcode + + class SynapseError(CodeMessageException): """A base exception type for matrix errors which have an errcode and error message (as well as an HTTP status code).