errors

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 5 Imported by: 51

README

errors Go Reference CI Coverage Code to Test Ratio Test Execution Time

errors + stack staces.

Key features of k1LoW/errors are:

  • Retain the stack traces once stacked as far as possible.
  • It is possible to output stack traces in structured data.
  • It is possible to separate joined errors.
  • Zero dependency

Usage

import (
    // "errors"
    "github.com/k1LoW/errors"
)

Example

https://go.dev/play/p/8zQvFThxI4O

Difference between errors and k1LoW/errors

References

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxStackDepth = 50

MaxStackDepth is the maximum depth of the stack trace.

Functions

func As

func As(err error, target any) bool

As is a wrapper for errors.As.

func Errors added in v1.1.0

func Errors(err error) []error

Errors returns all joined errors in the given error.

func Is

func Is(err, target error) bool

Is is a wrapper for errors.Is.

func Join

func Join(errs ...error) error

Join is a wrapper for errors.Join.

func New

func New(text string) error

New is a wrapper for errors.New.

func StackTraces

func StackTraces(err error) stackTraces

StackTraces returns the stack traces of the given error(s).

func Unwrap

func Unwrap(err error) error

Unwrap is a wrapper for errors.Unwrap.

func WithStack

func WithStack(err error) error

WithStack sets the stack trace for the given error.

Types

type Frame added in v0.3.0

type Frame struct {
	Name string `json:"name"`
	File string `json:"file"`
	Line int    `json:"line"`
}

Jump to

Keyboard shortcuts

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