@@ -21,7 +21,10 @@ class ExceptionFactory:
2121
2222 # Constants for formatting messages
2323 _FORMAT_RESPONSE_CODE_LINE = 'HTTP Response Code: {}'
24- _GLUE_ERROR_MESSAGES = '\n '
24+ _FORMAT_RESPONSE_ID_LINE = 'The response id to help bunq debug: {}'
25+ _FORMAT_ERROR_MESSAGE_LINE = 'Error message: {}'
26+ _GLUE_ERROR_MESSAGES_NEW_LINE = '\n '
27+ _GLUE_ERROR_MESSAGES_STRING_EMPTY = ''
2528
2629 @classmethod
2730 def create_exception_for_response (cls , response_code , messages ):
@@ -53,8 +56,9 @@ def create_exception_for_response(cls, response_code, messages):
5356 return UnknownApiErrorException (error_message , response_code )
5457
5558 @classmethod
56- def _generate_message_error (cls , response_code , messages ):
59+ def _generate_message_error (cls , response_code , messages , response_id ):
5760 """
61+ :type response_id: str
5862 :type response_code: int
5963 :type messages: list[str]
6064
@@ -63,8 +67,14 @@ def _generate_message_error(cls, response_code, messages):
6367
6468 line_response_code = cls ._FORMAT_RESPONSE_CODE_LINE \
6569 .format (response_code )
70+ line_response_id = cls ._FORMAT_RESPONSE_ID_LINE .format (response_id )
71+ line_error_message = cls ._FORMAT_ERROR_MESSAGE_LINE .format (
72+ cls ._GLUE_ERROR_MESSAGES_STRING_EMPTY .join (messages )
73+ )
6674
67- return cls ._glue_messages ([line_response_code ] + messages )
75+ return cls ._glue_messages (
76+ [line_response_code , line_response_id , line_error_message ]
77+ )
6878
6979 @classmethod
7080 def _glue_messages (cls , messages ):
@@ -74,4 +84,4 @@ def _glue_messages(cls, messages):
7484 :rtype: str
7585 """
7686
77- return cls ._GLUE_ERROR_MESSAGES .join (messages )
87+ return cls ._GLUE_ERROR_MESSAGES_NEW_LINE .join (messages )
0 commit comments