Skip to content
Snippets Groups Projects
Commit 31739b1a authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

export CodedCustomExceptionMetaclass

parent 75f975a9
No related branches found
No related tags found
No related merge requests found
# v2.5.10 # v2.5.10
* _TBA_ * exported CodedCustomExceptionMetaclass
# v2.5.9 # v2.5.9
......
...@@ -75,3 +75,9 @@ Note that this won't allow you to handle exceptions like that ...@@ -75,3 +75,9 @@ Note that this won't allow you to handle exceptions like that
self.fail() self.fail()
As this is a Python limitation. As this is a Python limitation.
The CodedCustomException uses the following metaclass to accomplish
it's magic
.. autoclass:: satella.exceptions.CodedCustomExceptionMetaclass
:members:
...@@ -4,7 +4,7 @@ import typing as tp ...@@ -4,7 +4,7 @@ import typing as tp
__all__ = ['BaseSatellaError', 'ResourceLockingError', 'ResourceNotLocked', 'ResourceLocked', __all__ = ['BaseSatellaError', 'ResourceLockingError', 'ResourceNotLocked', 'ResourceLocked',
'ConfigurationValidationError', 'ConfigurationError', 'ConfigurationSchemaError', 'ConfigurationValidationError', 'ConfigurationError', 'ConfigurationSchemaError',
'PreconditionError', 'MetricAlreadyExists', 'BaseSatellaException', 'CustomException', 'PreconditionError', 'MetricAlreadyExists', 'BaseSatellaException', 'CustomException',
'CodedCustomException'] 'CodedCustomException', 'CodedCustomExceptionMetaclass']
class CustomException(Exception): class CustomException(Exception):
...@@ -47,6 +47,9 @@ def get_base_of_bases(classes): ...@@ -47,6 +47,9 @@ def get_base_of_bases(classes):
class CodedCustomExceptionMetaclass(type): class CodedCustomExceptionMetaclass(type):
"""
Metaclass implementing the isinstance check for coded custom exceptions
"""
code = None # type: tp.Optional[tp.Any] code = None # type: tp.Optional[tp.Any]
def __instancecheck__(cls, instance): def __instancecheck__(cls, instance):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment