Skip to content

Local Error example in docs does not work #966

Open
@dtinth

Description

@dtinth

What version of Elysia is running?

1.2.2

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

Run the example from https://elysiajs.com/essential/life-cycle.html#local-error

The if clause is removed to simulate an error case.

import { Elysia } from "elysia";

new Elysia()
  .get("/", () => "Hello", {
    beforeHandle({ error }) {
      return error(401);
    },
    error({ error }) {
      return "Handled";
    },
  })
  .listen(3000);

What is the expected behavior?

"Handled"

What do you see instead?

The error hook is not called, got "Unauthorized" instead.

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions