errorpage

package
v0.25.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package errorpage renders the development error page.

It is the functional equivalent of Ignition, with one difference in scope: here the data comes from the Collector, which is part of the core, so the page knows the queries, the dumps, the events and the routes without any extra package installed.

Absolute rule: nothing in this package may be reachable when Env is not dev. The Recover middleware is the only caller, and it checks the flag first.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditorLink(editor, file string, line int) string

EditorLink builds the link that opens the file straight in the IDE.

It forwards to observability.EditorLink, which is where the one implementation lives: the console needs the same links, and two copies is two places to add the next editor.

func Render

func Render(w http.ResponseWriter, r *http.Request, panicValue any, col *observability.Collector, opts Options)

Render draws the full error page.

func RenderDump

func RenderDump(w http.ResponseWriter, r *http.Request, col *observability.Collector, opts Options)

RenderDump draws the dump page, for the DumpDie flow. It answers 200: the request was aborted on purpose, not by a failure.

Types

type Options

type Options struct {
	// Editor is the target of the "open in IDE" links: vscode, cursor, goland
	// or zed.
	Editor string
	// AppModule is the module path of the application, used to tell app frames
	// from framework and stdlib frames.
	AppModule string
	// Diagnose collects what the registered modules have to say about the state
	// of the system right now. Pass kernel.Diagnose.
	//
	// It exists because the most useful hint is often about something that
	// happened outside this request: the outbox has been stuck for four minutes,
	// the scheduler last ran an hour ago. A page that only looks at the request
	// cannot see any of it, and that is exactly the state where somebody is
	// staring at an error wondering what changed.
	Diagnose func(ctx context.Context) []string
}

Options carries what the page needs from the application configuration.

type StackFrame

type StackFrame struct {
	Func    string
	File    string
	Line    int
	IsApp   bool     // false for the runtime, the stdlib and the framework itself
	Snippet []string // surrounding lines, rendered inline
	SnipTop int      // line number of the first snippet line
}

StackFrame is one frame of the stack, already enriched with the source snippet around the failing line.

func Capture

func Capture(skip int, appModule string) []StackFrame

Capture collects the stack from skip onwards, marking which frames belong to the application. Same decision as Ignition: application frames are expanded by default and everything else is collapsed.

appModule is the caller's module path. When empty, every frame that is not runtime, stdlib or framework counts as application code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL