summaryrefslogtreecommitdiffstats
path: root/cobbler/cobbler_exception.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-05-08 15:02:06 -0400
committerJim Meyering <jim@meyering.net>2006-05-08 15:02:06 -0400
commitd4f71b4318fedf374844030095c6c8dd544f0e92 (patch)
treedd5bb88c2587a0ab4ea2638374ad4a71bbd868a9 /cobbler/cobbler_exception.py
parent038a4383ccb6230f927960a34288c5cf6fbd3455 (diff)
downloadthird_party-cobbler-d4f71b4318fedf374844030095c6c8dd544f0e92.tar.gz
third_party-cobbler-d4f71b4318fedf374844030095c6c8dd544f0e92.tar.xz
third_party-cobbler-d4f71b4318fedf374844030095c6c8dd544f0e92.zip
Interim checkin while straightening out exceptions. The last_error bit reminded me of the
thing I hated most about Microsoft SDK/DDK programming (that being, last_error and inconsistant error handling), so it had to go.
Diffstat (limited to 'cobbler/cobbler_exception.py')
-rw-r--r--cobbler/cobbler_exception.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/cobbler/cobbler_exception.py b/cobbler/cobbler_exception.py
new file mode 100644
index 0000000..c6abfce
--- /dev/null
+++ b/cobbler/cobbler_exception.py
@@ -0,0 +1,20 @@
+"""
+Custom error for fatal cobbler exceptions that come with human readable error messages.
+These can be caught and printed without stack traces.
+
+Michael DeHaan <mdehaan@redhat.com>
+"""
+
+import exceptions
+import cobbler_msg
+
+class CobblerException(exceptions.Exception):
+
+ def __init__(self, value, args=[]):
+ if type(args) == str or type(args) == int:
+ args = (args)
+ self.value = cobbler_msg.lookup(value) % args
+
+ def __str__(self):
+ return repr(self.value)
+