Revision c00f5f9f

b/commissioning/exception.py
1 1

  
2 2
class CallError(Exception):
3 3

  
4
    def __init__(self, *args, **kw):
4
    def __new__(cls, *args, **kw):
5 5
        call_error = kw.get('call_error', None)
6 6
        if call_error is None:
7
            call_error = self.__class__.__name__
7
            call_error = cls.__name__
8 8
        else:
9 9
            call_error = str(call_error)
10
        self.call_error = call_error
11
        self.args = tuple(str(a) for a in args)
10
        cls = globals().get(call_error, cls)
11
        self = Exception.__new__(cls, *args)
12
        return self
13

  
14
    def __init__(self, *args, **kw):
15
        self.call_error = kw.get('call_error', self.__class__.__name__)
16
        self.args = args
12 17

  
13 18
    def __str__(self):
14 19
    	return '\n--------\n'.join((self.call_error + ':',) + self.args)
15 20

  
21
    def __repr__(self):
22
        return '%s(%s)' % (self.__class__.__name__, ','.join(self.args))
23

  
16 24
    @classmethod
17 25
    def from_exception(cls, exc):
18 26
        args = None

Also available in: Unified diff