Documentation ¶
Index ¶
- Variables
- func AddHintFromGo(err error, fileset *token.FileSet, node ast.Node, hint string)
- func ColoursInErrors(enabled bool)
- func ExtractFromPanic(recovered any) error
- func Panic(list ErrorList)
- type Bailout
- type CharacterSet
- type ErrInSrc
- func (e *ErrInSrc) As(target any) bool
- func (e *ErrInSrc) Bailout()
- func (e *ErrInSrc) Error() string
- func (e *ErrInSrc) Is(target error) bool
- func (e *ErrInSrc) OnSameLine(other *ErrInSrc) bool
- func (e *ErrInSrc) StackTrace() errors.StackTrace
- func (e *ErrInSrc) Title() string
- func (e *ErrInSrc) Unwrap() error
- func (e *ErrInSrc) WithGoNode(fileset *token.FileSet, node ast.Node)
- type ErrorList
- type List
- type StackFrame
Constants ¶
This section is empty.
Variables ¶
var IncludeStackByDefault = false
IncludeStackByDefault is whether to include the stack by default on all errors. This is exported to allow Encore's CI platform to set this to true for CI/CD builds.
var TerminalWidth = 100
TerminalWidth is the width of the terminal in columns that we're rendering to.
We default to 100 characters, but the CLI overrides this when it renders errors. When using the value, note it might be very small (e.g. 5) if the user has shrunk their terminal window super small. Thus any code which uses this or creates new widths off it should cope with <= 0 values.
Functions ¶
func AddHintFromGo ¶
func ColoursInErrors ¶
func ColoursInErrors(enabled bool)
func ExtractFromPanic ¶
ExtractFromPanic returns the first ErrInSrc or ErrorList found in the recovered value.
If no value is recovered, then nil is returned.
Types ¶
type CharacterSet ¶
type CharacterSet struct { HorizontalBar rune VerticalBar rune CrossBar rune VerticalBreak rune VerticalGap rune UpArrow rune RightArrow rune LeftTop rune MiddleTop rune RightTop rune LeftBottom rune RightBottom rune MiddleBottom rune LeftBracket rune RightBracket rune LeftCross rune RightCross rune UnderBar rune Underline rune }
type ErrInSrc ¶
type ErrInSrc struct { // The parameters of the error // This is an internal data type to force the // creation of these inside `srcerrors` Params ErrParams `json:"params"` // The Stack trace of where the error was created within the Encore codebase // this will be empty if the error was created in a production build of Encore. // To populate this, build Encore with the tag `dev_build`. Stack []*StackFrame `json:"stack,omitempty"` }
ErrInSrc represents an error which occurred due to the source code of the application being run through Encore.
It supports the concept of one of more locations within the users source code which caused the error. The locations will be rendered in the final output.
Construct these using helper functions in the `srcerrors` package as we can use that as a central repository error types
func FromTemplate ¶ added in v1.14.5
FromTemplate returns a new ErrInSrc using the [errs.Template] as a template
func (*ErrInSrc) Bailout ¶
func (e *ErrInSrc) Bailout()
Bailout is a helper function which will abort the current process and report the error
func (*ErrInSrc) OnSameLine ¶
func (*ErrInSrc) StackTrace ¶
func (e *ErrInSrc) StackTrace() errors.StackTrace
StackTrace implements the StackTraceProvider interface for some libraries including ZeroLog, xerrors and Sentry
type StackFrame ¶
type StackFrame struct { ProgramCounter uintptr `json:"pc"` File string `json:"file"` Package string `json:"pkg"` Function string `json:"fun"` Line int `json:"line"` }
StackFrame represents a single frame in a Stack trace
func GetStack ¶
func GetStack() []*StackFrame