Categorygithub.com/saucelabs/customerror
modulepackage
1.0.4
Repository: https://github.com/saucelabs/customerror.git
Documentation: pkg.go.dev

# README

customerror

customerror provides the base block to create custom errors. It also provides built-in custom errors covering some common cases. A Custom Error provides context - a Message to an optionally wrapped Err. Additionally a Code - for example "E1010", and StatusCode can be provided. Both static (pre-created), and dynamic (in-line) errors can be easily created. Code helps a company build a catalog of errors, which helps, and improves customer service.

Install

$ go get github.com/saucelabs/[email protected]

Usage

See example_test.go, and customerror_test.go file.

Documentation

Run $ make doc or check out online.

Development

Check out CONTRIBUTION.

Release

  1. Update CHANGELOG accordingly.
  2. Once changes from MR are merged.
  3. Tag and release.

Roadmap

Check out CHANGELOG.

# Functions

New is the custom error factory.
NewFailedToError is the building block for errors usually thrown when some action failed, e.g: "Failed to create host".
NewInvalidError is the building block for errors usually thrown when something fail validation, e.g: "Invalid port".
NewMissingError is the building block for errors usually thrown when required information is missing, e.g: "Missing host".
NewRequiredError is the building block for errors usually thrown when required information is missing, e.g: "Port is required".
WithCode allows to specify an error code, such as "E1010".
WithError allows to specify an error which will be wrapped by the custom error.
WithStatusCode allows to specify the status code, such as "200".
Wrap `customError` around `errors`.

# Structs

CustomError is the base block to create custom errors.

# Type aliases

Option allows to define error options.