mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-05 09:53:33 +03:00
CAPI: Reinstate/format post-query exceptions/etc in AppWindow
This commit is contained in:
parent
407bc9f53a
commit
7f362be740
@ -942,17 +942,14 @@ class AppWindow(object):
|
||||
"""Handle the resulting data from a CAPI query."""
|
||||
try:
|
||||
data = self.capi_response_queue.get(block=False)
|
||||
|
||||
except queue.Empty:
|
||||
logger.error('There was no response in the queue!')
|
||||
# TODO: Set status text
|
||||
return
|
||||
|
||||
else:
|
||||
if isinstance(data, companion.CAPIFailedRequest):
|
||||
logger.trace_if('capi.worker', f'Failed Request: {data.message}')
|
||||
if data.exception:
|
||||
raise data.exception
|
||||
|
||||
else:
|
||||
raise ValueError(data.message)
|
||||
|
||||
# Validation
|
||||
if 'commander' not in data:
|
||||
# This can happen with EGS Auth if no commander created yet
|
||||
@ -1073,33 +1070,38 @@ class AppWindow(object):
|
||||
|
||||
self.holdofftime = querytime + companion.holdoff
|
||||
|
||||
# # Companion API problem
|
||||
# except companion.ServerLagging as e:
|
||||
# err = str(e)
|
||||
# if retrying:
|
||||
# self.status['text'] = err
|
||||
# play_bad = True
|
||||
#
|
||||
# else:
|
||||
# # Retry once if Companion server is unresponsive
|
||||
# self.w.after(int(SERVER_RETRY * 1000), lambda: self.capi_request_data(event, True))
|
||||
# return # early exit to avoid starting cooldown count
|
||||
#
|
||||
# except companion.CmdrError as e: # Companion API return doesn't match Journal
|
||||
# err = self.status['text'] = str(e)
|
||||
# play_bad = True
|
||||
# companion.session.invalidate()
|
||||
# self.login()
|
||||
#
|
||||
# except companion.ServerConnectionError as e:
|
||||
# logger.warning(f'Exception while contacting server: {e}')
|
||||
# err = self.status['text'] = str(e)
|
||||
# play_bad = True
|
||||
#
|
||||
# except Exception as e: # Including CredentialsError, ServerError
|
||||
# logger.debug('"other" exception', exc_info=e)
|
||||
# err = self.status['text'] = str(e)
|
||||
# play_bad = True
|
||||
except queue.Empty:
|
||||
logger.error('There was no response in the queue!')
|
||||
# TODO: Set status text
|
||||
return
|
||||
|
||||
# Companion API problem
|
||||
except companion.ServerLagging as e:
|
||||
err = str(e)
|
||||
if retrying:
|
||||
self.status['text'] = err
|
||||
play_bad = True
|
||||
|
||||
else:
|
||||
# Retry once if Companion server is unresponsive
|
||||
self.w.after(int(SERVER_RETRY * 1000), lambda: self.capi_request_data(event, True))
|
||||
return # early exit to avoid starting cooldown count
|
||||
|
||||
except companion.CmdrError as e: # Companion API return doesn't match Journal
|
||||
err = self.status['text'] = str(e)
|
||||
play_bad = True
|
||||
companion.session.invalidate()
|
||||
self.login()
|
||||
|
||||
except companion.ServerConnectionError as e:
|
||||
logger.warning(f'Exception while contacting server: {e}')
|
||||
err = self.status['text'] = str(e)
|
||||
play_bad = True
|
||||
|
||||
except Exception as e: # Including CredentialsError, ServerError
|
||||
logger.debug('"other" exception', exc_info=e)
|
||||
err = self.status['text'] = str(e)
|
||||
play_bad = True
|
||||
|
||||
if not err: # not self.status['text']: # no errors
|
||||
# LANG: Time when we last obtained Frontier CAPI data
|
||||
|
Loading…
x
Reference in New Issue
Block a user