[kupfer: 27/67] Implement kupfer.obj.exceptions



commit 3f44ea4e3ca6ccab358c519fde5c21ce6df12730
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Mar 15 22:52:31 2011 +0100

    Implement kupfer.obj.exceptions

 kupfer/obj/exceptions.py |   31 +++++++++++++++++++++++++++++++
 kupfer/objects.py        |    1 +
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/obj/exceptions.py b/kupfer/obj/exceptions.py
new file mode 100644
index 0000000..3bb5c25
--- /dev/null
+++ b/kupfer/obj/exceptions.py
@@ -0,0 +1,31 @@
+from kupfer import kupferstring
+from kupfer.obj.base import OperationError
+
+class LocaleOperationError (OperationError):
+	"""
+	User-visible error created from locale-encoded
+	error message (for example OSError)
+	"""
+	def __init__(self, s):
+		OperationError.__init__(self, kupferstring.fromlocale(s))
+
+class CommandMissingError (OperationError):
+	"""
+	User-visible error message for missing executable
+	"""
+	def __init__(self, cmd):
+		OperationError.__init__(self, _("Command '%s' not found"))
+
+class NotAvailableError (OperationError):
+	"""
+	User-visible error message when an external
+	tool is the wrong version
+	"""
+	def __init__(self, toolname):
+		OperationError.__init__(self,
+		               _("%s does not support this operation") % toolname)
+
+class NoMultiError (OperationError):
+	def __init__(self):
+		OperationError.__init__(self,
+		               _("Can not be used with multiple objects"))
diff --git a/kupfer/objects.py b/kupfer/objects.py
index a201d16..fbeaf30 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -1,4 +1,5 @@
 from kupfer.obj.base import *
+from kupfer.obj.exceptions import *
 from kupfer.obj.objects import FileLeaf, AppLeaf, UrlLeaf, TextLeaf
 from kupfer.obj.objects import RunnableLeaf, SourceLeaf
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]