Added better error handling/printing
This commit is contained in:
parent
c974528d2c
commit
b8a2c1b871
2 changed files with 10 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import os
|
|||
import time
|
||||
import queue
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from .controller import Controller, ControllerTypes
|
||||
from ..bluez import BlueZ
|
||||
|
|
@ -92,9 +93,9 @@ class ControllerServer():
|
|||
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
self.state["state"] = "crashed"
|
||||
self.state["errors"] = str(e)
|
||||
self.state["errors"] = traceback.format_exc()
|
||||
return self.state
|
||||
|
||||
def mainloop(self, itr, ctrl):
|
||||
|
|
|
|||
|
|
@ -320,6 +320,7 @@ class InputTUI():
|
|||
|
||||
state = None
|
||||
spinner = LoadingSpinner()
|
||||
errors = None
|
||||
try:
|
||||
with term.cbreak(), term.keypad(), term.location(), term.hidden_cursor():
|
||||
print(term.home + term.clear)
|
||||
|
|
@ -346,6 +347,9 @@ class InputTUI():
|
|||
loading_text = "Reconnecting to Nintendo Switch"
|
||||
elif state == "connected":
|
||||
loading_text = "Connected!"
|
||||
elif state == "crashed":
|
||||
errors = self.nx.state[self.controller_index]["errors"]
|
||||
exit(1)
|
||||
self.render_start_screen(term, loading_text)
|
||||
|
||||
print(term.move_y((term.height // 2) + 6))
|
||||
|
|
@ -369,6 +373,9 @@ class InputTUI():
|
|||
pass
|
||||
finally:
|
||||
print(term.clear())
|
||||
if errors:
|
||||
print("The TUI encountered the following errors:")
|
||||
print(errors)
|
||||
|
||||
def remote_input_loop(self, term):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue