Minor improvement of error handling.

Also removes ignore of broken pipe from 5ca090668 since this is not
handling it the right way (see #60).
main
Olivier Mangin 8 years ago
parent d4c18ad1a4
commit a02f67f133

@ -1,19 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
import sys
from pubs import pubs_cmd from pubs import pubs_cmd
try:
pubs_cmd.execute() pubs_cmd.execute()
except BrokenPipeError:
# stdout or stderr has been closed, cleaning up
try:
sys.stdout.close()
except IOError:
pass
try:
sys.stderr.close()
except IOError:
pass

@ -84,4 +84,5 @@ def execute(raw_args=sys.argv):
args.func(conf, args) args.func(conf, args)
except Exception as e: except Exception as e:
uis.get_ui().handle_exception(e) if not uis.get_ui().handle_exception(e):
raise

@ -84,11 +84,14 @@ class PrintUI(object):
sys.exit(error_code) sys.exit(error_code)
def handle_exception(self, exc): def handle_exception(self, exc):
if self.debug: """Attempts to handle exception.
raise
else: :returns: True if exception has been handled (currently never happens)
"""
if not self.debug:
self.error(ustr(exc)) self.error(ustr(exc))
self.exit() self.exit()
return False
class InputUI(PrintUI): class InputUI(PrintUI):

Loading…
Cancel
Save