errorcode

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 1 Imported by: 3

README

go-error-code CI

An opinionated module for bubbling up and consuming exit codes alongside errors. Useful for packages that are used by CLIs to return helpful codes to the caller without having to parse error strings.

install

go get github.com/frantjc/go-error-code

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) int

func HTTPStatusCode added in v0.2.0

func HTTPStatusCode(err error) int

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

func New

func New(err error, opts ...ErrorOpt) *Error

func (*Error) ExitCode

func (e *Error) ExitCode() int

func (*Error) HTTPStatusCode added in v0.2.0

func (e *Error) HTTPStatusCode() int

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorOpt

type ErrorOpt func(*Error)

func WithExitCode

func WithExitCode(exitCode int) ErrorOpt

func WithHTTPStatusCode added in v0.2.0

func WithHTTPStatusCode(httpStatusCode int) ErrorOpt

Jump to

Keyboard shortcuts

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