Skip to content

Commit

Permalink
add non retriable error
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin67 committed Nov 23, 2023
1 parent b394659 commit 3887de9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/inngest/router/invoke.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ defmodule Inngest.Router.Invoke do
{400, error}
end
rescue
non_retry in Inngest.NonRetriableError ->
{400, non_retry.message}

err ->
{400, err.message}
catch
Expand Down
23 changes: 23 additions & 0 deletions test/support/cases/non_retry_error.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule Inngest.Test.Case.NonRetriableError do
@moduledoc false

use Inngest.Function
alias Inngest.{FnOpts, Trigger}

@func %FnOpts{id: "non-retry-fn", name: "Non Retriable Function"}
@trigger %Trigger{event: "test/plug.no-retry"}

@impl true
def exec(ctx, %{step: step} = _args) do
_success = step.run(ctx, "should-work", fn -> "foobar" end)

_fail =
step.run(ctx, "should-fail", fn ->
raise Inngest.NonRetriableError, message: "not retrying!"
end)

_ = step.run(ctx, "should-not-run", fn -> "yolo" end)

{:ok, "completed"}
end
end

0 comments on commit 3887de9

Please sign in to comment.