package xerrors

import "git.sr.ht/~jamesponddotco/xstd-go/xerrors"

Package xerrors provides helper functions and types for error handling.

Example

Code:play 

package main

import (
	"fmt"
	"os"

	"git.sr.ht/~jamesponddotco/xstd-go/xerrors"
)

func main() {
	const errOpenFile xerrors.Error = "failed to open file"

	if _, err := os.Open("file-does-not-exist.txt"); err != nil {
		fmt.Println(fmt.Errorf("%w: %w", errOpenFile, err))
	}
}

Output:

failed to open file: open file-does-not-exist.txt: no such file or directory

Index

Examples

Types

type Error

type Error string

Error is an imuutable error type.

func (Error) Error

func (e Error) Error() string

Error implements the error interface for Error.

Source Files

error.go xerrors.go

Version
v0.13.1 (latest)
Published
Jan 29, 2025
Platform
linux/amd64
Last checked
3 days ago

Tools for package owners.