diff options
| author | Christian Theune <ct@gocept.com> | 2007-05-03 21:59:32 +0000 |
|---|---|---|
| committer | Christian Theune <ct@gocept.com> | 2007-05-03 21:59:32 +0000 |
| commit | a025dca5f2dc2e74575ebd43ea616d6f67e6026e (patch) | |
| tree | 811d75a6d333355932ea0bfe63e2765bc795aaca /src/zope/interface/exceptions.py | |
| parent | 6e287d3cffe6087dad31fc2310b3de45d324d396 (diff) | |
| download | zope-interface-a025dca5f2dc2e74575ebd43ea616d6f67e6026e.tar.gz | |
Moving code to satellite.
Diffstat (limited to 'src/zope/interface/exceptions.py')
| -rw-r--r-- | src/zope/interface/exceptions.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/zope/interface/exceptions.py b/src/zope/interface/exceptions.py new file mode 100644 index 0000000..237a841 --- /dev/null +++ b/src/zope/interface/exceptions.py @@ -0,0 +1,69 @@ +############################################################################## +# +# Copyright (c) 2002 Zope Corporation and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +"""Interface-specific exceptions + +$Id$ +""" + +class Invalid(Exception): + """A specification is violated + """ + +class DoesNotImplement(Invalid): + """ This object does not implement """ + def __init__(self, interface): + self.interface = interface + + def __str__(self): + return """An object does not implement interface %(interface)s + + """ % self.__dict__ + +class BrokenImplementation(Invalid): + """An attribute is not completely implemented. + """ + + def __init__(self, interface, name): + self.interface=interface + self.name=name + + def __str__(self): + return """An object has failed to implement interface %(interface)s + + The %(name)s attribute was not provided. + """ % self.__dict__ + +class BrokenMethodImplementation(Invalid): + """An method is not completely implemented. + """ + + def __init__(self, method, mess): + self.method=method + self.mess=mess + + def __str__(self): + return """The implementation of %(method)s violates its contract + because %(mess)s. + """ % self.__dict__ + +class InvalidInterface(Exception): + """The interface has invalid contents + """ + +class BadImplements(TypeError): + """An implementation assertion is invalid + + because it doesn't contain an interface or a sequence of valid + implementation assertions. + """ |
