Try rescue raise - keep original stacktrace

Hi there,

in our code we use macro to encapsulate all the usec-cases in our app. We log runtime and outcome of the usecase. In case of errors we log the message and stacktrace as well.
But in case of errors we are raising the error again after logging and thus we loose the original stacktrace. It would be nice in development to keep the original stacktrace. Not sure if that is possible

try do
  # call use_case
  e -> log_error(e, System.stacktrace)
       raise e # but keep the original stack-trace

1 Like

Take a look at Kernel.reraise/2.


I think that is exactly what I am looking for. Thx

1 Like