Revision 96a212f7 snf-common/synnefo/lib/commissioning/exception.py
b/snf-common/synnefo/lib/commissioning/exception.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
|
35 |
def str_or_utf8(s): |
|
36 |
if isinstance(s, unicode): |
|
37 |
return s.encode('utf8') |
|
38 |
return str(s) |
|
39 |
|
|
40 |
|
|
35 | 41 |
class CallError(Exception): |
36 | 42 |
exceptions = {} |
37 | 43 |
|
... | ... | |
51 | 57 |
self.kwargs = kw |
52 | 58 |
|
53 | 59 |
def __str__(self): |
54 |
return '\n--------\n'.join(str(x) for x in self.args) |
|
60 |
return '\n--------\n'.join(str_or_utf8(x) for x in self.args)
|
|
55 | 61 |
|
56 | 62 |
def __repr__(self): |
57 | 63 |
return '%s(%s)' % (self.__class__.__name__, |
58 |
','.join(str(x) for x in self.args)) |
|
64 |
','.join(str_or_utf8(x) for x in self.args))
|
|
59 | 65 |
|
60 | 66 |
@classmethod |
61 | 67 |
def from_exception(cls, exc): |
Also available in: Unified diff