diff options
| author | troido <troido@protonmail.com> | 2018-05-22 19:09:47 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2018-05-22 19:09:47 +0200 |
| commit | 60404a13810dd5807ec6ab440d284c391f23bcb4 (patch) | |
| tree | 594553741c9fccd9d0f37a94f6b4af6b5a69cb1e /asciifarm/client/start.py | |
| parent | 0df7f7850c0f36067c2fec5d7e0c508b36330b20 (diff) | |
client raises exceptions outside main curses wrapper
Diffstat (limited to 'asciifarm/client/start.py')
| -rw-r--r-- | asciifarm/client/start.py | 11 |
1 files changed, 10 insertions, 1 deletions
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) |
