From 53bbc48597fa598a2c1a5ee780bda0efee679462 Mon Sep 17 00:00:00 2001 From: "Yaakov M. Nemoy" Date: Thu, 2 Oct 2008 19:22:06 -0400 Subject: Added exception for bad function call. We can use this to deliver *good* inforamtion to the user what went wrong, and how to rectify it if possible. --- base/base.py | 7 ++++++- base/exceptions.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'base') diff --git a/base/base.py b/base/base.py index 68677bc..afa0df4 100644 --- a/base/base.py +++ b/base/base.py @@ -8,6 +8,7 @@ from os.path import join, dirname from module import Module from vars import __description__, __version__, header, prompt +from exceptions import ModuleError, ExecutionException log = logging.getLogger('devshell') @@ -165,7 +166,11 @@ def do_command(data, top=None): params += [param] output = None if len(params): - output = top(*params) + try: + output = top(*params) + except ExecutionException, e: + # TODO: maket his as helpful as possible to the user + log.critical('execution of command failed because: %s' % e.message) if module: return output, module, mod_params diff --git a/base/exceptions.py b/base/exceptions.py index 471dd0e..221b73e 100644 --- a/base/exceptions.py +++ b/base/exceptions.py @@ -2,3 +2,8 @@ class ModuleError(Exception): def __init__(self, reason, error): self.reason = reason self.error = error + +class ExecutionException(Exception): + def __init__(self, e, message): + self.e = e + self.message = message \ No newline at end of file -- cgit