Skip to content
This repository was archived by the owner on Apr 12, 2018. It is now read-only.

Commit add6013

Browse files
author
Oleiade
committed
Enhance swf errors wrapping via an exception helper
1 parent 52a7398 commit add6013

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

swf/exceptions.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,47 @@
55
#
66
# See the file LICENSE for copying permission.
77

8+
class SWFError(Exception):
9+
def __init__(self, message, raw_error, *args):
10+
Exception.__init__(self, message, *args)
11+
self.kind, self.details = raw_error.split(':')
812

9-
class PollTimeout(Exception):
13+
def __repr__(self):
14+
msg = self.message
15+
16+
if self.kind and self.details:
17+
msg += '\nReason: {}, {}'.format(self.kind, self.details)
18+
19+
return msg
20+
21+
def __str__(self):
22+
msg = self.message
23+
24+
if self.kind and self.details:
25+
msg += '\nReason: {}, {}'.format(self.kind, self.details)
26+
27+
return msg
28+
29+
30+
class PollTimeout(SWFError):
1031
pass
1132

1233

13-
class InvalidCredentialsError(Exception):
34+
class InvalidCredentialsError(SWFError):
1435
pass
1536

1637

17-
class ResponseError(Exception):
38+
class ResponseError(SWFError):
1839
pass
1940

2041

21-
class DoesNotExistError(Exception):
42+
class DoesNotExistError(SWFError):
2243
pass
2344

2445

25-
class AlreadyExistsError(Exception):
46+
class AlreadyExistsError(SWFError):
2647
pass
2748

2849

29-
class InvalidKeywordArgumentError(Exception):
50+
class InvalidKeywordArgumentError(SWFError):
3051
pass

0 commit comments

Comments
 (0)