compact

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RolePriority = []FrameRole{
	RoleOrigin,
	RoleStack,
}

RolePriority defines the order in which frame roles should be processed or displayed.

Functions

func GroupedFormatter

func GroupedFormatter(frames FramesRoles, processor Processor) []byte

GroupedFormatter formats frames grouped by their role.

Each role is rendered as a separate section headed by the role name, followed by the frames that belong to that role.

Example:

ORIGIN
	main.main [cmd/app/main.go:10]

STACK
	service.Run [internal/service/run.go:42]
	handler.Execute [internal/handler/execute.go:17]

func InlineFormatter

func InlineFormatter(frames FramesRoles, processor Processor) []byte

InlineFormatter formats frames as a flat list.

Frames marked as RoleOrigin are prefixed with "->" while all other frames use a neutral marker.

Example:

-> main.main [cmd/app/main.go:10]
   service.Run [internal/service/run.go:42]
   handler.Execute [internal/handler/execute.go:17]

func Stack

func Stack(formatter Formatter, opts ...option) stack.Provider

Stack returns a stack provider that captures the current stack trace and formats it using the provided formatter and options.

func WithProcessor

func WithProcessor(processor Processor) option

WithProcessor configures the Processor used to transform frame paths before they are formatted.

Types

type Formatter

type Formatter func(FramesRoles, Processor) []byte

Formatter formats a collection of stack frames into a compact textual representation.

type FrameRole

type FrameRole string

FrameRole identifies the role of a stack frame within a processed stack trace.

const (
	// RoleOrigin marks the frame where the panic or error originated.
	RoleOrigin FrameRole = "origin"

	// RoleStack marks a regular stack frame that is part of the execution path.
	RoleStack FrameRole = "stack"
)

type FramesRoles

type FramesRoles map[FrameRole][]stackFrame

FramesRoles groups stack frames by their assigned role.

type Processor

type Processor func(path string) string

Processor transforms a stack frame path into a different representation.

func EmptyProcessor

func EmptyProcessor() Processor

EmptyProcessor returns a Processor that leaves paths unchanged.

func StandardProcessor

func StandardProcessor() Processor

StandardProcessor returns a Processor that converts absolute file paths into paths relative to the current project when possible.

If the project root cannot be determined, the returned Processor leaves paths unchanged.

Jump to

Keyboard shortcuts

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