mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
More succint error reporting on network connection/timeout.
This commit is contained in:
parent
b0b1dd5a9f
commit
437997e963
@ -5,6 +5,7 @@ import sys
|
||||
from sys import platform
|
||||
from os import mkdir
|
||||
from os.path import expanduser, isdir, join
|
||||
import requests
|
||||
from time import time, localtime, strftime
|
||||
|
||||
import Tkinter as tk
|
||||
@ -224,9 +225,18 @@ class AppWindow:
|
||||
except companion.VerificationRequired:
|
||||
return prefs.AuthenticationDialog(self.w, self.verify)
|
||||
|
||||
# Companion API problem
|
||||
except companion.ServerError as e:
|
||||
self.status['text'] = str(e)
|
||||
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
if __debug__: print_exc()
|
||||
self.status['text'] = "Error: Can't connect to EDDN"
|
||||
|
||||
except requests.exceptions.Timeout as e:
|
||||
if __debug__: print_exc()
|
||||
self.status['text'] = "Error: Connection to EDDN timed out"
|
||||
|
||||
except Exception as e:
|
||||
if __debug__: print_exc()
|
||||
self.status['text'] = str(e)
|
||||
|
13
companion.py
13
companion.py
@ -113,7 +113,12 @@ class Session:
|
||||
raise CredentialsError()
|
||||
else:
|
||||
self.credentials = { 'email' : username, 'password' : password }
|
||||
r = self.session.post('https://companion.orerve.net/user/login', data = self.credentials, timeout=timeout)
|
||||
try:
|
||||
r = self.session.post('https://companion.orerve.net/user/login', data = self.credentials, timeout=timeout)
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
raise ServerError()
|
||||
|
||||
if r.status_code != requests.codes.ok:
|
||||
self.dump(r)
|
||||
r.raise_for_status()
|
||||
@ -147,7 +152,11 @@ class Session:
|
||||
self.login()
|
||||
elif self.state == Session.STATE_AUTH:
|
||||
raise VerificationRequired()
|
||||
r = self.session.get('https://companion.orerve.net/profile', timeout=timeout)
|
||||
try:
|
||||
r = self.session.get('https://companion.orerve.net/profile', timeout=timeout)
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
raise ServerError()
|
||||
|
||||
if r.status_code != requests.codes.ok:
|
||||
self.dump(r)
|
||||
|
Loading…
x
Reference in New Issue
Block a user