Print error data in import notifications

This commit is contained in:
Romuald Juchnowicz-Bierbasz
2019-09-19 11:17:01 +02:00
committed by Romuald Bierbasz
parent 4d6d3b8eb2
commit 392e4c5f68
2 changed files with 14 additions and 15 deletions

View File

@@ -18,6 +18,17 @@ class JsonRpcError(Exception):
def __eq__(self, other):
return self.code == other.code and self.message == other.message and self.data == other.data
def json(self):
obj = {
"code": self.code,
"message": self.message
}
if self.data is not None:
obj["error"]["data"] = self.data
return obj
class ParseError(JsonRpcError):
def __init__(self):
super().__init__(-32700, "Parse error")
@@ -232,15 +243,9 @@ class Server():
response = {
"jsonrpc": "2.0",
"id": request_id,
"error": {
"code": error.code,
"message": error.message
}
"error": error.json()
}
if error.data is not None:
response["error"]["data"] = error.data
self._send(response)
@staticmethod

View File

@@ -331,10 +331,7 @@ class Plugin:
def _game_achievements_import_failure(self, game_id: str, error: ApplicationError) -> None:
params = {
"game_id": game_id,
"error": {
"code": error.code,
"message": error.message
}
"error": error.json()
}
self._notification_client.notify("game_achievements_import_failure", params)
@@ -398,10 +395,7 @@ class Plugin:
def _game_time_import_failure(self, game_id: str, error: ApplicationError) -> None:
params = {
"game_id": game_id,
"error": {
"code": error.code,
"message": error.message
}
"error": error.json()
}
self._notification_client.notify("game_time_import_failure", params)