Skip to content

Commit a727616

Browse files
author
Kevin Hellemun
committed
Pass response id to exceptions in exception factory. (#59)
1 parent 4817075 commit a727616

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

bunq/sdk/exception_factory.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,69 @@ class ExceptionFactory:
2727
_GLUE_ERROR_MESSAGES_STRING_EMPTY = ''
2828

2929
@classmethod
30-
def create_exception_for_response(cls, response_code, messages):
30+
def create_exception_for_response(
31+
cls,
32+
response_code,
33+
messages,
34+
response_id
35+
):
3136
"""
37+
:type response_id: str
3238
:type response_code: int
3339
:type messages: list[str]
3440
3541
:return: The exception according to the status code.
3642
:rtype: ApiException
3743
"""
3844

39-
error_message = cls._generate_message_error(response_code, messages)
45+
error_message = cls._generate_message_error(
46+
response_code,
47+
messages,
48+
response_id
49+
)
4050

4151
if response_code == cls._HTTP_RESPONSE_CODE_BAD_REQUEST:
42-
return BadRequestException(error_message, response_code)
52+
return BadRequestException(
53+
error_message,
54+
response_code,
55+
response_id
56+
)
4357
if response_code == cls._HTTP_RESPONSE_CODE_UNAUTHORIZED:
44-
return UnauthorizedException(error_message, response_code)
58+
return UnauthorizedException(
59+
error_message,
60+
response_code,
61+
response_id
62+
)
4563
if response_code == cls._HTTP_RESPONSE_CODE_FORBIDDEN:
46-
return ForbiddenException(error_message, response_code)
64+
return ForbiddenException(
65+
error_message,
66+
response_code,
67+
response_id
68+
)
4769
if response_code == cls._HTTP_RESPONSE_CODE_NOT_FOUND:
48-
return NotFoundException(error_message, response_code)
70+
return NotFoundException(
71+
error_message,
72+
response_code,
73+
response_id
74+
)
4975
if response_code == cls._HTTP_RESPONSE_CODE_METHOD_NOT_ALLOWED:
50-
return MethodNotAllowedException(error_message, response_code)
76+
return MethodNotAllowedException(
77+
error_message,
78+
response_code,
79+
response_id
80+
)
5181
if response_code == cls._HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS:
52-
return TooManyRequestsException(error_message, response_code)
82+
return TooManyRequestsException(
83+
error_message,
84+
response_code,
85+
response_id
86+
)
5387
if response_code == cls._HTTP_RESPONSE_CODE_INTERNAL_SERVER_ERROR:
54-
return PleaseContactBunqException(error_message, response_code)
88+
return PleaseContactBunqException(
89+
error_message,
90+
response_code,
91+
response_id
92+
)
5593

5694
return UnknownApiErrorException(error_message, response_code)
5795

0 commit comments

Comments
 (0)