errxit

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 4 Imported by: 0

README

errxit

Go Documentation Go Report Card builds.sr.ht status

Package errxit is a simple and, hopefully, idiomatic error handling library for Go designed primarily for CLI applications. It combines error messages with exit codes, similar to the classic errno concept.

Why?

I got tired of implementing this idea over and over again in my projects, so I wrote this library.

Installation

To install errxit and use it in your project, run:

go get git.sr.ht/~jamesponddotco/errxit-go@latest

Contributing

Anyone can help make errxit better. Send patches to the mailing list and report bugs on the issue tracker.

You must sign-off your work using git commit --signoff. Follow the Linux kernel developer's certificate of origin for more details.

All contributions are made under the MIT License.

Resources

The following resources are available:


Released under the MIT License.

Documentation

Overview

Package errxit provides a simple and, hopefully, idiomatic interface for error handling designed primarily for CLI applications.

Package errxit provides a simple and, hopefully, idiomatic interface for error handling designed primarily for CLI applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit(err error)

Exit is a convenience function that calls os.Exit with the error code associated with the error.

Types

type Error

type Error struct {
	// Err is the underlying error.
	Err error

	// No is the error code associated with the error.
	No int
}

Error represents an error with an associated error code.

func New

func New(err error, code int) *Error

New returns a new Error instance with the given error code.

func (*Error) Code

func (e *Error) Code() int

Code returns the error code.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap added in v1.1.0

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

Jump to

Keyboard shortcuts

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