diff options
author | Lars Wirzenius <liw@liw.fi> | 2009-11-26 22:02:14 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2009-11-26 22:02:14 +0200 |
commit | ee8116d326d24c6d8c3bf418a92bf5b957310534 (patch) | |
tree | 0fd8476e3376c3c1cc5b1bcba44970e21aac2bbd /obnam | |
parent | a4388c41ca90f65643a27bf2d41a7b5c6d51fd3b (diff) | |
download | obnam-ee8116d326d24c6d8c3bf418a92bf5b957310534.tar.gz |
Introduce obnamlib.AppException, the base class for all obnam-specific exceptions.
Use that instead of a naked Exception everywhere.
Have main script log and print out stack traces when an exception happens, except
when it's an AppException.
Add a command interpreter to the App class.
Diffstat (limited to 'obnam')
-rwxr-xr-x | obnam | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -15,5 +15,19 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging +import sys +import traceback + import obnamlib -obnamlib.App().run() +try: + obnamlib.App().run() +except obnamlib.AppException, e: + logging.critical(str(e)) + sys.stderr.write('Error: %s\n' % str(e)) + sys.exit(1) +except BaseException, e: + logging.critical(traceback.format_exc()) + sys.stderr.write(traceback.format_exc()) + sys.exit(1) + |