xerrors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 0 Imported by: 8

Documentation

Overview

Package xerrors provides helper functions and types for error handling.

Example
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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

Jump to

Keyboard shortcuts

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