Skip to content

Conversation

Rutgerdj
Copy link
Contributor

@Rutgerdj Rutgerdj commented Sep 24, 2025

When an exception occured inside of a Reactor.Step it would not show the stacktrace but only the error message. This change includes the stacktrace in the exception and also adds a test that validates this.

This only works for "named" steps. The easiest way to also make it work for anonymous steps would be to remove the rescue clause from the AnonFn.run/3 function:
https://github.com/ash-project/reactor/blob/df74431bd1bc62a1c8935f86a65fc86abe13a9f4/lib/reactor/step/anon_fn.ex#L32C1-L33C29

Changing the AnonFn.run/3 would be a breaking change so I wanted to discuss that first.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

When an exception occured inside of a Reactor.Step it would not show the stacktrace but only the error message.
This change includes the stacktrace in the exception and also adds a test that validates this
@jimsynz
Copy link
Contributor

jimsynz commented Sep 24, 2025

Changing the AnonFn.run/3 would be a breaking change so I wanted to discuss that first.

You know I think just removing the rescue would work, as then the error would be correctly handled by the step runner rescue that you've modified. Do you want to include that in this change?

Copy link
Contributor

@jimsynz jimsynz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect!

@Rutgerdj
Copy link
Contributor Author

You know I think just removing the rescue would work, as then the error would be correctly handled by the step runner rescue that you've modified. Do you want to include that in this change?

Raised errors inside of a pipeline are indeed handled by the step_runner so that would not be an issue. But there is a test that explicitly checks if an AnonFn rescues errors:

https://github.com/Rutgerdj/reactor/blob/072ec552e0d7ec61c0d16774f3725c8a84bce990/test/reactor/step/anon_fn_test.exs#L23-L28

@jimsynz
Copy link
Contributor

jimsynz commented Sep 25, 2025

Raised errors inside of a pipeline are indeed handled by the step_runner so that would not be an issue. But there is a test that explicitly checks if an AnonFn rescues errors:

Meh. Just remove it :)

This prevented the stacktrace from being passed down to the executor.
@Rutgerdj
Copy link
Contributor Author

Alright removed the rescue statement in the AnonFn and also updated the tests to verify that the line numbers are correct

@jimsynz
Copy link
Contributor

jimsynz commented Sep 26, 2025

🎉 thanks for the contribution! 🎉

@jimsynz jimsynz merged commit a0ea80c into ash-project:main Sep 26, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants