mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-28 12:08:34 +08:00
17 lines
477 B
Python
17 lines
477 B
Python
from textwrap import dedent
|
|
|
|
class CustomException(Exception):
|
|
argmap = {0: 'classname'}
|
|
|
|
def __init__(self, *args):
|
|
self.args = args
|
|
|
|
def format(self):
|
|
assert len(self.args) == len(self.argmap), \
|
|
"""Wrong number of arguments passed to custom exception %s.""" \
|
|
% self.__class__
|
|
return self.message.format(**dict(zip(self.argmap, self.args)))
|
|
|
|
def __str__(self):
|
|
return dedent(self.format()).strip('\n')
|