March Docs

Bastion.ErrorOverlay

Bastion.ErrorOverlay — dev-mode error overlay.

Provides:

  1. rescue_errors/1 plug — stub (no-op until HttpServer.try_call is available).
  2. router_plug/1 — mounts /_bastion/debug/:session_id (returns 404 stub).
  3. render_error_page/2 — renders a rich HTML 500 page for dev mode.

The crash REPL is not yet available (requires March.Repl, not yet implemented).

The debug endpoint and rich error page are hard-gated at runtime on Bastion.Dev.dev_env(): outside dev the plug answers 404 and the error page degrades to a plain 500 without exception details. You can still additionally guard the mount in your router, but production safety does not depend on it.

Typical setup in your router:

import Bastion.ErrorOverlay

conn |> ErrorOverlay.router_plug()

Functions

fndebug_socketdebug_socket(conn, _session_id : String)#

Handle /_bastion/debug/:session_id WebSocket requests.

NOTE: Crash REPL not yet available (requires March.Repl). Returns 404 for now.

fnrender_error_pagerender_error_page(conn, err_msg : String)#

Render a 500 error page with error message.

In dev mode this is the rich overlay including the error message. In any other environment it degrades to a plain "Internal Server Error" page so exception details (paths, SQL, secrets in messages) never reach clients.

fnrescue_errorsrescue_errors(conn)#

Wrap the next pipeline step in error recovery.

NOTE: Not yet implemented — returns conn unchanged until HttpServer.try_call is available.

fnrouter_plugrouter_plug(conn)#

Route plug: intercept /_bastion/debug/:id requests.

Hard-gated at runtime on Bastion.Dev.dev_env() — outside dev the endpoint answers a plain 404 (indistinguishable from a missing route) regardless of how the app mounted it, so a forgotten if dev_env?() in a router cannot expose the debug surface in production.