1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-21 11:27:38 +03:00

EDDN: Catch and log 'we tried to send empty market'.

Very tight check on this to be sure we don't ignore other errors.

	r.status_code == 400  # Not a different code
	$schemaRef == commodities
	The message had empty commodities list
	r.text == expected return from EDDN Gateway
This commit is contained in:
Athanasius 2020-09-28 12:26:09 +01:00
parent 9564d8ab4f
commit ca4214fff8

@ -140,19 +140,22 @@ class EDDN:
r = self.session.post(self.UPLOAD, data=json.dumps(to_send), timeout=self.TIMEOUT)
if r.status_code != requests.codes.ok:
# Check if EDDN is still objecting to an empty commodities list
if r.status_code == 400 \
and msg['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' \
and msg['message']['commodities'] == [] \
and r.text == "FAIL: [<ValidationError: '[] is too short'>]":
logger.trace("EDDN is still objecting to empty commodities data")
return # We want to silence warnings otherwise
logger.debug(f'''Status from POST wasn't OK:
Status\t{r.status_code}
URL\t{r.url}
Headers\t{r.headers}
Content:\n{r.text}
Msg:\n{msg}''')
# Check if EDDN is still objecting to an empty commodities list
if r.status_code == 400 \
and msg['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' \
and this.commodities == [] \
and r.text == "FAIL: [<ValidationError: '[] is too short'>]":
logger.trace("EDDN is still objecting to empty commodities data")
Msg:\n{msg}'''
)
r.raise_for_status()