Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
pingsutw committed Aug 21, 2024
1 parent 0542f76 commit 3c031c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
8 changes: 4 additions & 4 deletions flytekit/bin/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,16 @@ def get_traceback_str(e: Exception) -> str:
if isinstance(e, FlyteUserRuntimeException):
# If the exception is a user exception, we want to capture the traceback of the exception that was raised by the
# user code, not the Flyte internals.
tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__
err = e.__cause__ if e.__cause__ else e
else:
tb = e.__traceback__
err = e
tb = e.__traceback__
lines = traceback.format_tb(tb)
lines = [line.rstrip() for line in lines]
tb_str = "\n ".join(lines)
format_str = "Traceback (most recent call last):\n" "\n {traceback}\n" "\n" "Message:\n" "\n" " {message}"

value = e.value if isinstance(e, FlyteUserRuntimeException) else e
return format_str.format(traceback=tb_str, message=f"{type(value).__name__}: {value}")
return format_str.format(traceback=tb_str, message=f"{type(err).__name__}: {err}")


def get_one_of(*args) -> str:
Expand Down
2 changes: 1 addition & 1 deletion flytekit/core/base_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def dispatch_execute(
# If the task is being executed locally, we want to raise the original exception
e.args = (f"Error encountered while executing '{self.name}':\n {e.args[0]}",)
raise
raise FlyteUserRuntimeException(e) from e
raise FlyteUserRuntimeException("flytekit runtime error. Original error message: {e}") from e

if inspect.iscoroutine(native_outputs):
# If native outputs is a coroutine, then this is an eager workflow.
Expand Down
13 changes: 0 additions & 13 deletions flytekit/exceptions/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ class FlyteUserException(_FlyteException):
class FlyteUserRuntimeException(_FlyteException):
_ERROR_CODE = "USER:RuntimeError"

def __init__(self, exc_value: Exception):
"""
FlyteUserRuntimeException is thrown when a user code raises an exception.
:param exc_value: The exception that was raised from user code.
"""
self._exc_value = exc_value
super().__init__(str(exc_value))

@property
def value(self):
return self._exc_value


class FlyteTypeException(FlyteUserException, TypeError):
_ERROR_CODE = "USER:TypeError"
Expand Down

0 comments on commit 3c031c7

Please sign in to comment.