errs

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(message string, options ...Option) error

New creates a framework/business error.

func Wrap

func Wrap(err error) error

Wrap attaches caller information to an existing error.

Types

type Error

type Error struct {
	Code    string
	Message string
	Params  Map
	Cause   error
	// contains filtered or unexported fields
}

Error is Runa's framework/business error.

func As

func As(err error) *Error

As returns a errs Error when err contains one.

func (*Error) Error

func (err *Error) Error() string

Error returns the business error message.

func (*Error) ErrorParams

func (err *Error) ErrorParams() core.Map

ErrorParams returns translation/rendering parameters.

func (*Error) Source

func (err *Error) Source() string

Source returns the top source frame captured when this error was created.

func (*Error) Stack

func (err *Error) Stack() []Frame

Stack returns captured source frames.

func (*Error) StackTrace

func (err *Error) StackTrace() string

StackTrace returns captured source frames formatted as text.

func (*Error) Unwrap

func (err *Error) Unwrap() error

Unwrap returns the cause error.

func (*Error) WithCode

func (err *Error) WithCode(code string) *Error

WithCode sets a business error code.

func (*Error) WithParams

func (err *Error) WithParams(params Map) *Error

WithParams sets business error parameters.

type Frame

type Frame struct {
	File     string
	Line     int
	Function string
}

Frame describes one captured error source frame.

func (Frame) String

func (frame Frame) String() string

String formats the source frame as file:line function.

type Map

type Map = core.Map

Map stores error attributes.

type Option

type Option func(*Error)

Option configures a framework/business error.

func Attr

func Attr(key string, value any) Option

Attr sets a single business error attribute.

func Cause

func Cause(cause error) Option

Cause sets the cause error.

func Code

func Code(code string) Option

Code sets the business error code.

func Params

func Params(params Map) Option

Params sets business error parameters.

Jump to

Keyboard shortcuts

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