summaryrefslogtreecommitdiff
path: root/obnam
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2009-11-26 22:02:14 +0200
committerLars Wirzenius <liw@liw.fi>2009-11-26 22:02:14 +0200
commitee8116d326d24c6d8c3bf418a92bf5b957310534 (patch)
tree0fd8476e3376c3c1cc5b1bcba44970e21aac2bbd /obnam
parenta4388c41ca90f65643a27bf2d41a7b5c6d51fd3b (diff)
downloadobnam-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-xobnam16
1 files changed, 15 insertions, 1 deletions
diff --git a/obnam b/obnam
index 59ccd3a3..aaf5b23f 100755
--- a/obnam
+++ b/obnam
@@ -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)
+