update: more exception info included

This commit is contained in:
2026-04-17 10:06:10 +08:00
parent d3502f7a86
commit b64cae1b7f
2 changed files with 15 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "common"
description = "Reusable code stubs"
version = "0.1.7"
version = "0.1.8"
requires-python = ">=3.13"
authors = [
{ name="BreakerBear", email="breakerbear@autistic.men" },

View File

@@ -68,7 +68,7 @@ class Error(Enum):
INTERNAL_ERROR = -32603
def __init__(self, *args):
super().__init__(args)
super().__init__(*args)
self.data = None
def message(self) -> str:
@@ -140,10 +140,19 @@ async def handler(request: ws.WebSocketRequest):
inbound = Request.load(message)
mid = inbound.id
res = inbound.fulfill()
except json.decoder.JSONDecodeError: err = Error.PARSE_ERROR
except Request.ParamsError: err = Error.INVALID_PARAMS
except TypeError: err = Error.INVALID_REQUEST
except KeyError: err = Error.METHOD_NOT_FOUND
except json.decoder.JSONDecodeError as e:
err = Error.PARSE_ERROR
exc = e
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:
logger.critical('Going away', exc_info=e)
return