Accessing original thrown value from Effect.runPromise

In Svelte-kit server endpoints (in +server.ts files), you can return a redirect response by using the Svelte-kit exported function redirect(status: StatusCode, location: string | URL): never. This function will throw with an instance of a class Redirect. Svelte-kit will catch errors that are thrown by your handlers and detect if they are an instance of this class Redirect. If so, they return a redirect response.

Consider this endpoint:

export const POST = async ({ request }): Promise<Response> => Effect.runPromise(
  Effect.tryPromise(async () => {
    redirect(302, '/other-location'); // redirect will `throw new Redirect(...)`
  });
);


My intention is that the thrown Redirect will make its way back to Svelte-kit, but instead Effect throws a FiberFailure. How can I get the original thrown value?

See this Effect playground for a minimal reproduction, without Svelte-kit: https://effect.website/play#75ab306c1adc
Was this page helpful?