liberrors

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: ISC Imports: 4 Imported by: 0

README

Errors Library

Detailed, pretty-printed colorful errors for Go.

Check out the test/ directory for examples.

────────────────────────────────
 [!] Internal Error
    in nested_file.txt:0:2
    └─ from /tmp/some/path/to/a/file.txt:6:9

    5 |  Hello World
    6 |  testing <——

 >>> This is an example error body

Documentation

Index

Constants

View Source
const (
	ERR_INTERNAL = "Internal Error"
	ERR_ASSERT   = "Assertion Error"
	ERR_IO       = "I/O Error"
	ERR_READ     = "Reading Error"
	ERR_WRITE    = "Writing Error"
	ERR_SYNTAX   = "Syntax Error"
	ERR_FORMAT   = "Formatting Error"
	ERR_VALIDATE = "Validation Error"
	ERR_EXECUTE  = "Execution Error"
	ERR_CONVERT  = "Conversion Error"
)

Suggested values for DetailedError.Label

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	FirstLine   uint
	Buffer      string
	Highlighted string
}

func (Buffer) IsEmpty

func (buffer Buffer) IsEmpty() bool

func (Buffer) Print

func (buffer Buffer) Print(writer io.Writer)

type Context

type Context interface {
	Print(io.Writer)
}

type DetailedError

type DetailedError struct {
	Label   string
	Context Context
	Details string
}

func NewIO

func NewIO(err error, path string) *DetailedError

Constructor for the most common error

func (*DetailedError) Error

func (err *DetailedError) Error() string

func (*DetailedError) Print

func (err *DetailedError) Print(writer io.Writer)

type DirContext

type DirContext struct {
	Path string
}

func NewDirContext added in v1.0.2

func NewDirContext(path string) DirContext

func (DirContext) Print

func (context DirContext) Print(writer io.Writer)

type FileContext

type FileContext struct {
	Trace  []TraceItem
	Buffer Buffer
}

func (FileContext) Print

func (context FileContext) Print(writer io.Writer)

type TraceItem

type TraceItem struct {
	Name string
	// Use negative values to hide it from the output
	Col, Row int
}

func (TraceItem) PrintNested

func (item TraceItem) PrintNested(writer io.Writer)

func (TraceItem) PrintRoot

func (item TraceItem) PrintRoot(writer io.Writer)

Jump to

Keyboard shortcuts

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