diagnostics

package
v5.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(parseReport Report)

Emit writes the formatted report to stderr.

func WriteHTTPError

func WriteHTTPError(parseW http.ResponseWriter, parseStatus int, parseReport Report)

WriteHTTPError emits the report to the server log and writes the CLIENT-SAFE subset (Report.FormattedPublic — summary/code/next/docs only) as a plain-text HTTP error response. It deliberately does NOT send stack frames, absolute build paths (which disclose the OS username / server filesystem layout), or the where/path/error/runtime detail to the client — that lives in the server log via Emit. Use WriteHTTPErrorVerbose only for a trusted/dev diagnostics endpoint where the full report in the response body is intended (#60).

This lives behind !js so browser/wasm builds never link net/http: that import chain (http → crypto/tls → x509 → dnsmessage) costs roughly a megabyte of wasm for a helper only servers can call.

func WriteHTTPErrorVerbose

func WriteHTTPErrorVerbose(parseW http.ResponseWriter, parseStatus int, parseReport Report)

WriteHTTPErrorVerbose is the opt-in full-disclosure variant: it writes the complete Formatted() report (including stack frames and build paths) to the HTTP client. Use it ONLY on trusted/local diagnostics endpoints; never on a public error path.

Types

type Options

type Options struct {
	Summary       string
	Code          string
	Headline      string
	Path          string
	Runtime       string
	Next          string
	Docs          string
	SkipFunctions []string
}

type Report

type Report struct {
	Summary         string
	Code            string
	Headline        string
	Where           string
	Path            string
	Error           string
	Runtime         string
	Next            string
	Docs            string
	AppFrames       []string
	FrameworkFrames []string
	PlatformFrames  []string
}

func Build

func Build(parseOptions Options) Report

Build constructs a Report from the given Options, capturing and classifying a stack trace.

func (Report) Formatted

func (parseReport Report) Formatted() string

func (Report) FormattedPublic

func (parseReport Report) FormattedPublic() string

FormattedPublic returns a client-safe rendering of the report: only the app-authored fields (summary, code/headline, next step, docs link). It deliberately OMITS where/path/error/runtime and every stack frame — those come from debug.Stack() and embed absolute build paths (which leak the OS username and the server's filesystem layout) plus internal call structure. That detail belongs in the server log (Emit → stderr), never in an HTTP response body sent to an untrusted client.

Jump to

Keyboard shortcuts

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