package xerrors
import "git.sr.ht/~jamesponddotco/xstd-go/xerrors"
Package xerrors provides helper functions and types for error handling.
Code:play
Output:
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))
}
}
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 ¶
Error implements the error interface for Error.
Source Files ¶
- Version
- v0.13.1 (latest)
- Published
- Jan 29, 2025
- Platform
- linux/amd64
- Last checked
- 3 days ago –
Tools for package owners.