From 3887de9e6823d474e7e5603366ff469d79108c97 Mon Sep 17 00:00:00 2001 From: Darwin D Wu Date: Thu, 23 Nov 2023 12:36:12 -0800 Subject: [PATCH] add non retriable error --- lib/inngest/router/invoke.ex | 3 +++ test/support/cases/non_retry_error.ex | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/support/cases/non_retry_error.ex diff --git a/lib/inngest/router/invoke.ex b/lib/inngest/router/invoke.ex index 78ea81e..ee02761 100644 --- a/lib/inngest/router/invoke.ex +++ b/lib/inngest/router/invoke.ex @@ -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 diff --git a/test/support/cases/non_retry_error.ex b/test/support/cases/non_retry_error.ex new file mode 100644 index 0000000..6565d01 --- /dev/null +++ b/test/support/cases/non_retry_error.ex @@ -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