refrakt/dev_error

Development error page.

Shows a rich HTML error page when a request crashes in dev mode. Includes the error message, stack trace, request details, and matched route information.

Usage

Use it in place of wisp.rescue_crashes, in development only. The page shows the error, a stack trace and every request header, so it must never be served in production:

import refrakt/dev_error

fn rescue_crashes(req, ctx, next) {
  case ctx.config.env {
    config.Dev -> dev_error.rescue(req, next)
    config.Test | config.Prod -> wisp.rescue_crashes(next)
  }
}

Projects generated by refrakt new already do this in router.gleam.

Values

pub fn rescue(
  req: request.Request(wisp.Connection),
  handler: fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body)

Rescue crashes and show a detailed error page. Only use this in development; when the handler doesn’t crash, it is transparent.

✨ Search Document