summaryrefslogtreecommitdiffstats
path: root/ipalib/errors.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-29 03:48:33 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-29 03:48:33 +0000
commit8dc0e263dac8bf4074e48fcca593a00cadec03e0 (patch)
treeccb5985edba304a9d456abfb4d75f4a3990e17d2 /ipalib/errors.py
parent61b5b7a8488c2e3392905df3f6e7e02b7302fdd8 (diff)
downloadfreeipa-8dc0e263dac8bf4074e48fcca593a00cadec03e0.tar.gz
freeipa-8dc0e263dac8bf4074e48fcca593a00cadec03e0.tar.xz
freeipa-8dc0e263dac8bf4074e48fcca593a00cadec03e0.zip
221: Added errors.IPATypeError exception; added new test_errors.py module with corresponding unit tests
Diffstat (limited to 'ipalib/errors.py')
-rw-r--r--ipalib/errors.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index a25df091a..70128f7ca 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -21,6 +21,26 @@
All custom errors raised by `ipalib` package.
"""
+
+class IPATypeError(TypeError):
+ """
+ TypeError subclass with standard message for easier debugging.
+
+ Also has two custom attributes:
+
+ ``type`` - The type being tested against.
+ ``value`` - The offending value that caused the exception.
+ """
+
+ format = 'need a %r; got %r'
+
+ def __init__(self, type_, value):
+ assert type(value) is not type, 'no error: %r, %r' % (type_, value)
+ self.type = type_
+ self.value = value
+ TypeError.__init__(self, self.format % (self.type, self.value))
+
+
class IPAError(Exception):
"""
Use this base class for your custom IPA errors unless there is a