Skip to content

Commit

Permalink
✨ Fix empty internal_message empty when ExceptionWithDisplayMessage r…
Browse files Browse the repository at this point in the history
…aised (#36901)
  • Loading branch information
strosek committed Apr 9, 2024
1 parent 09ccec3 commit 23c280b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Expand Up @@ -13,3 +13,6 @@ class ExceptionWithDisplayMessage(Exception):
def __init__(self, display_message: str, **kwargs: Any):
super().__init__(**kwargs)
self.display_message = display_message

def __str__(self) -> str:
return f'ExceptionWithDisplayMessage: "{self.display_message}"'
8 changes: 8 additions & 0 deletions airbyte-cdk/python/unit_tests/test_exception_handler.py
Expand Up @@ -10,6 +10,7 @@
import pytest
from airbyte_cdk.exception_handler import assemble_uncaught_exception
from airbyte_cdk.models import AirbyteErrorTraceMessage, AirbyteLogMessage, AirbyteMessage, AirbyteTraceMessage
from airbyte_cdk.sources.streams.concurrent.exceptions import ExceptionWithDisplayMessage
from airbyte_cdk.utils.traced_exception import AirbyteTracedException


Expand All @@ -25,6 +26,13 @@ def test_given_exception_not_traced_exception_when_assemble_uncaught_exception_t
assert isinstance(assembled_exception, AirbyteTracedException)


def test_given_exception_with_display_message_when_assemble_uncaught_exception_then_internal_message_contains_display_message():
display_message = "some display message"
exception = ExceptionWithDisplayMessage(display_message)
assembled_exception = assemble_uncaught_exception(type(exception), exception)
assert display_message in assembled_exception.internal_message


def test_uncaught_exception_handler():
cmd = "from airbyte_cdk.logger import init_logger; from airbyte_cdk.exception_handler import init_uncaught_exception_handler; logger = init_logger('airbyte'); init_uncaught_exception_handler(logger); raise 1"
exception_message = "exceptions must derive from BaseException"
Expand Down

0 comments on commit 23c280b

Please sign in to comment.