summaryrefslogtreecommitdiffstats
path: root/ipalib/errors2.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-01-03 17:27:53 -0700
committerJason Gerard DeRose <jderose@redhat.com>2009-01-03 17:27:53 -0700
commit6b6e6b1cab7a633faf16631a565ecb6988dadb48 (patch)
tree86b5b24485955ac3186beb7e350b77c47fefa5b3 /ipalib/errors2.py
parentd1517b95ca14773773647434fb589c8224307328 (diff)
downloadfreeipa-6b6e6b1cab7a633faf16631a565ecb6988dadb48.tar.gz
freeipa-6b6e6b1cab7a633faf16631a565ecb6988dadb48.tar.xz
freeipa-6b6e6b1cab7a633faf16631a565ecb6988dadb48.zip
Ported plugin registration errors into errors2.py; plugable.Registrar now raises new errors2 exceptions
Diffstat (limited to 'ipalib/errors2.py')
-rw-r--r--ipalib/errors2.py83
1 files changed, 74 insertions, 9 deletions
diff --git a/ipalib/errors2.py b/ipalib/errors2.py
index 676dd79f3..7793a9146 100644
--- a/ipalib/errors2.py
+++ b/ipalib/errors2.py
@@ -43,7 +43,7 @@ import request
class PrivateError(StandardError):
"""
- Base class for exceptions that are *never* returned in an RPC response.
+ Base class for exceptions that are *never* forwarded in an RPC response.
"""
format = ''
@@ -72,15 +72,82 @@ class SubprocessError(PrivateError):
1
>>> e.argv
('/bin/false',)
+ >>> e.message
+ "return code 1 from ('/bin/false',)"
>>> str(e)
"return code 1 from ('/bin/false',)"
"""
+
format = 'return code %(returncode)d from %(argv)r'
+class PluginSubclassError(PrivateError):
+ """
+ Raised when a plugin doesn't subclass from an allowed base.
+
+ For example:
+
+ >>> raise PluginSubclassError(plugin='bad', bases=('base1', 'base2'))
+ Traceback (most recent call last):
+ ...
+ PluginSubclassError: 'bad' not subclass of any base in ('base1', 'base2')
+
+ """
+
+ format = '%(plugin)r not subclass of any base in %(bases)r'
+
+
+class PluginDuplicateError(PrivateError):
+ """
+ Raised when the same plugin class is registered more than once.
+
+ For example:
+
+ >>> raise PluginDuplicateError(plugin='my_plugin')
+ Traceback (most recent call last):
+ ...
+ PluginDuplicateError: 'my_plugin' was already registered
+ """
+
+ format = '%(plugin)r was already registered'
+
+
+class PluginOverrideError(PrivateError):
+ """
+ Raised when a plugin overrides another without using ``override=True``.
+
+ For example:
+
+ >>> raise PluginOverrideError(base='Command', name='env', plugin='my_env')
+ Traceback (most recent call last):
+ ...
+ PluginOverrideError: unexpected override of Command.env with 'my_env'
+ """
+
+ format = 'unexpected override of %(base)s.%(name)s with %(plugin)r'
+
+
+class PluginMissingOverrideError(PrivateError):
+ """
+ Raised when a plugin overrides another that has not been registered.
+
+ For example:
+
+ >>> raise PluginMissingOverrideError(base='Command', name='env', plugin='my_env')
+ Traceback (most recent call last):
+ ...
+ PluginMissingOverrideError: Command.env not registered, cannot override with 'my_env'
+ """
+
+ format = '%(base)s.%(name)s not registered, cannot override with %(plugin)r'
+
+
+
+##############################################################################
+# Public errors:
class PublicError(StandardError):
"""
- **900** Base class for exceptions that can be returned in an RPC response.
+ **900** Base class for exceptions that can be forwarded in an RPC response.
"""
code = 900
@@ -96,8 +163,6 @@ class PublicError(StandardError):
-
-
class InternalError(PublicError):
"""
**901** Used to conceal a non-public exception.
@@ -108,7 +173,7 @@ class InternalError(PublicError):
##############################################################################
-# 1000 - 1999: Authentication Errors
+# 1000 - 1999: Authentication errors
class AuthenticationError(PublicError):
"""
**1000** Base class for authentication errors (*1000 - 1999*).
@@ -119,7 +184,7 @@ class AuthenticationError(PublicError):
##############################################################################
-# 2000 - 2999: Authorization Errors
+# 2000 - 2999: Authorization errors
class AuthorizationError(PublicError):
"""
**2000** Base class for authorization errors (*2000 - 2999*).
@@ -130,7 +195,7 @@ class AuthorizationError(PublicError):
##############################################################################
-# 3000 - 3999: Invocation Errors
+# 3000 - 3999: Invocation errors
class InvocationError(PublicError):
"""
@@ -201,7 +266,7 @@ class ValidationError(InvocationError):
##############################################################################
-# 4000 - 4999: Execution Errors
+# 4000 - 4999: Execution errors
class ExecutionError(PublicError):
"""
@@ -213,7 +278,7 @@ class ExecutionError(PublicError):
##############################################################################
-# 5000 - 5999: Generic Errors
+# 5000 - 5999: Generic errors
class GenericError(PublicError):
"""