summaryrefslogtreecommitdiff
path: root/asciifarm
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2018-05-22 19:09:47 +0200
committertroido <troido@protonmail.com>2018-05-22 19:09:47 +0200
commit60404a13810dd5807ec6ab440d284c391f23bcb4 (patch)
tree594553741c9fccd9d0f37a94f6b4af6b5a69cb1e /asciifarm
parent0df7f7850c0f36067c2fec5d7e0c508b36330b20 (diff)
client raises exceptions outside main curses wrapper
Diffstat (limited to 'asciifarm')
-rw-r--r--[-rwxr-xr-x]asciifarm/client/main.py0
-rw-r--r--asciifarm/client/start.py11
2 files changed, 10 insertions, 1 deletions
diff --git a/asciifarm/client/main.py b/asciifarm/client/main.py
index da556ef..da556ef 100755..100644
--- a/asciifarm/client/main.py
+++ b/asciifarm/client/main.py
diff --git a/asciifarm/client/start.py b/asciifarm/client/start.py
index fef5d9e..0c247b5 100644
--- a/asciifarm/client/start.py
+++ b/asciifarm/client/start.py
@@ -23,6 +23,7 @@ def main(name, socketType, address, keybindings, characters, colours=False, logf
print("ERROR: Could not connect to server.\nAre you sure that the server is running and that you're connecting to the right address?", file=sys.stderr)
return
+ error = None
closeMessage = None
os.environ.setdefault("ESCDELAY", "25")
@@ -34,10 +35,18 @@ def main(name, socketType, address, keybindings, characters, colours=False, logf
client.start()
except KeyboardInterrupt:
client.close("^C caught, goodbye")
+ except Exception as e:
+ # throw the execption outside ncurses
+ # so the cleanup can happen first
+ nonlocal error
+ error = e
nonlocal closeMessage
closeMessage = client.closeMessage
-
+
curses.wrapper(start)
+ if error is not None:
+ raise error
+
if closeMessage:
print(closeMessage, file=sys.stderr)