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