1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-20 19:07:38 +03:00

Merge pull request #1142 from A-UNDERSCORE-D/fix/503-eddn-more-verbose-error

Made EDDN logs more verbose
This commit is contained in:
Athanasius 2021-06-07 17:14:19 +01:00 committed by GitHub
commit 93e19ba33c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -621,3 +621,12 @@
/* stats.py: Status dialog title; In files: stats.py:375; */
"Ships" = "Ships";
/* EDDN returned schema too old warning [plugins/eddn.py] */
"EDDN Error: EDMC is too old for EDDN. Please update." = "EDDN Error: EDMC is too old for EDDN. Please update.";
/* EDDN returned 400 status code [plugins/eddn.py] */
"EDDN Error: Validation Failed (EDMC Too Old?). See Log" = "EDDN Error: Validation Failed (EDMC Too Old?). See Log";
/* EDDN returned unknown HTTP status code [plugins/eddn.py] */
"EDDN Error: Returned {STATUS} status code" = "EDDN Error: Returned {STATUS} status code";

View File

@ -255,6 +255,9 @@ Msg:\n{msg}'''
if not len(self.replaylog) % self.REPLAYFLUSH:
self.flush()
except requests.exceptions.HTTPError as e:
status['text'] = self.http_error_to_log(e)
except requests.exceptions.RequestException as e:
logger.debug('Failed sending', exc_info=e)
status['text'] = _("Error: Can't connect to EDDN")
@ -267,6 +270,24 @@ Msg:\n{msg}'''
self.parent.after(self.REPLAYPERIOD, self.sendreplay)
@staticmethod
def http_error_to_log(exception: requests.exceptions.HTTPError) -> str:
"""Convert an exception from raise_for_status to a log message and displayed error."""
status_code = exception.errno
if status_code == 429: # HTTP UPGRADE REQUIRED
logger.warning('EDMC is sending schemas that are too old')
return _('EDDN Error: EDMC is too old for EDDN. Please update.')
elif status_code == 400:
# we a validation check or something else.
logger.warning(f'EDDN Error: {status_code} -- {exception.response}')
return _('EDDN Error: Validation Failed (EDMC Too Old?). See Log')
else:
logger.warning(f'Unknown status code from EDDN: {status_code} -- {exception.response}')
return _('EDDN Error: Returned {STATUS} status code').format(status_code)
def export_commodities(self, data: Mapping[str, Any], is_beta: bool, is_odyssey: bool) -> None: # noqa: CCR001
"""
Update EDDN with the commodities on the current (lastStarport) station.