update: more exception info included
This commit is contained in:
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
[project]
|
[project]
|
||||||
name = "common"
|
name = "common"
|
||||||
description = "Reusable code stubs"
|
description = "Reusable code stubs"
|
||||||
version = "0.1.7"
|
version = "0.1.8"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="BreakerBear", email="breakerbear@autistic.men" },
|
{ name="BreakerBear", email="breakerbear@autistic.men" },
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class Error(Enum):
|
|||||||
INTERNAL_ERROR = -32603
|
INTERNAL_ERROR = -32603
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super().__init__(args)
|
super().__init__(*args)
|
||||||
self.data = None
|
self.data = None
|
||||||
|
|
||||||
def message(self) -> str:
|
def message(self) -> str:
|
||||||
@@ -140,10 +140,19 @@ async def handler(request: ws.WebSocketRequest):
|
|||||||
inbound = Request.load(message)
|
inbound = Request.load(message)
|
||||||
mid = inbound.id
|
mid = inbound.id
|
||||||
res = inbound.fulfill()
|
res = inbound.fulfill()
|
||||||
except json.decoder.JSONDecodeError: err = Error.PARSE_ERROR
|
except json.decoder.JSONDecodeError as e:
|
||||||
except Request.ParamsError: err = Error.INVALID_PARAMS
|
err = Error.PARSE_ERROR
|
||||||
except TypeError: err = Error.INVALID_REQUEST
|
exc = e
|
||||||
except KeyError: err = Error.METHOD_NOT_FOUND
|
except Request.ParamsError as e:
|
||||||
|
err = Error.INVALID_PARAMS
|
||||||
|
exc = e
|
||||||
|
except TypeError as e:
|
||||||
|
err = Error.INVALID_REQUEST
|
||||||
|
exc = e
|
||||||
|
except KeyError as e:
|
||||||
|
err = Error.METHOD_NOT_FOUND
|
||||||
|
err.data = str(e)
|
||||||
|
exc = e
|
||||||
except ws.ConnectionClosed as e:
|
except ws.ConnectionClosed as e:
|
||||||
logger.critical('Going away', exc_info=e)
|
logger.critical('Going away', exc_info=e)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user