Skip to content

Commit 392e4c5

Browse files
committed
Print error data in import notifications
1 parent 4d6d3b8 commit 392e4c5

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/galaxy/api/jsonrpc.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ def __init__(self, code, message, data=None):
1818
def __eq__(self, other):
1919
return self.code == other.code and self.message == other.message and self.data == other.data
2020

21+
def json(self):
22+
obj = {
23+
"code": self.code,
24+
"message": self.message
25+
}
26+
27+
if self.data is not None:
28+
obj["error"]["data"] = self.data
29+
30+
return obj
31+
2132
class ParseError(JsonRpcError):
2233
def __init__(self):
2334
super().__init__(-32700, "Parse error")
@@ -232,15 +243,9 @@ def _send_error(self, request_id, error):
232243
response = {
233244
"jsonrpc": "2.0",
234245
"id": request_id,
235-
"error": {
236-
"code": error.code,
237-
"message": error.message
238-
}
246+
"error": error.json()
239247
}
240248

241-
if error.data is not None:
242-
response["error"]["data"] = error.data
243-
244249
self._send(response)
245250

246251
@staticmethod

src/galaxy/api/plugin.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ def _game_achievements_import_success(self, game_id: str, achievements: List[Ach
331331
def _game_achievements_import_failure(self, game_id: str, error: ApplicationError) -> None:
332332
params = {
333333
"game_id": game_id,
334-
"error": {
335-
"code": error.code,
336-
"message": error.message
337-
}
334+
"error": error.json()
338335
}
339336
self._notification_client.notify("game_achievements_import_failure", params)
340337

@@ -398,10 +395,7 @@ def _game_time_import_success(self, game_time: GameTime) -> None:
398395
def _game_time_import_failure(self, game_id: str, error: ApplicationError) -> None:
399396
params = {
400397
"game_id": game_id,
401-
"error": {
402-
"code": error.code,
403-
"message": error.message
404-
}
398+
"error": error.json()
405399
}
406400
self._notification_client.notify("game_time_import_failure", params)
407401

0 commit comments

Comments
 (0)