Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bubble up the error from aggregate failure #506

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yordis
Copy link
Contributor

@yordis yordis commented Oct 5, 2022

Context

We are getting many of these errors, but we do not have many insights into what exactly happens.
This helps us to assess what is failing.

{:exit, _reason} ->
{:error, :aggregate_execution_failed}
{:exit, reason} ->
{:error, {:aggregate_execution_failed, reason}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{:error, {:aggregate_execution_failed, reason}}
{:error, :aggregate_execution_failed, reason}

Returning three elements tuple could be more compatible.

  1. the result handles in the next codes can handle these results;
    {:error, error} ->
    pipeline
    |> Pipeline.respond({:error, error})
    |> after_failure(payload)
    {:error, error, reason} ->
    pipeline
    |> Pipeline.assign(:error_reason, reason)
    |> Pipeline.respond({:error, error})
    |> after_failure(payload)
    end
  2. by adding new middleware to returning {:error, {:aggregate_execution_failed, reason}}, you can get the reason of a aggregate_execution_failed error from the dispatching result.

(note: I'm not a maintainer, just commenting)

Copy link

Choose a reason for hiding this comment

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

I've always found "three-element tuples" to be more trouble. Often, consuming code wants to bubble up errors. Two-element tuples make that easy to detect. Three-element tuples require the surrounding code to add possibly many different matches. As such, I vastly prefer to have the error "reason" become a tuple (or struct) rather than to change the shape of the return value.

@slashdotdash
Copy link
Member

slashdotdash commented Jan 9, 2024

We really need at least one test to demonstrate what this change is doing, verify it works as expected, and to ensure that it cannot be inadvertently broken with any future changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants