function / @typed/ui

handleHttpServerError

Converts Effect HTTP server errors into empty 400, 404, or 500 responses. Other failures remain in the global error channel.

Learn this UI primitive →

Package version
1.0.0-beta.13
Category
HTTP error responses
Since
1.0.0

Import

import { handleHttpServerError } from "@typed/ui";

Signatures

export declare function handleHttpServerError(router: HttpRouter): Effect.Effect<void, never, HttpRouterRequest<"GlobalError", unknown>>;

Why

Effect’s structured server failures have a safe transport status, whereas application/domain errors must remain visible for deliberate handling.

Ownership and lifetime

The middleware is installed on the supplied router and runs in each request lifetime. It allocates no long-lived resource and does not log, swallow, or reclassify non-HttpServerError failures.

Examples

import { handleHttpServerError } from "@typed/ui/HttpRouter"
import { Effect } from "effect"
import * as HttpRouter from "effect/unstable/http/HttpRouter"

const router = Effect.gen(function* () {
  const router = yield* HttpRouter.make
  yield* handleHttpServerError(router)
  return router
})

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source