custom

command
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 1 Imported by: 0

README

Custom Error Types

Complex custom error types that carry additional context can of course also be easily defined. In go an error is any type that implements Error() string.

When you ask goerr to print a stack trace it will attempt to marshal the error chain's "cause" into JSON, revealing even more contextual information.

You should notice in this example there are 3 pieces of information.

  • The error message,
  • the status code &
  • the full stacktrace.

Expected Output

http request failed

{
    "StatusCode": 500
}

main.crash1:C:/Users/brad.jones/Projects/Personal/goerr/examples/custom/main.go:19
        return goerr.Wrap(&httpError{StatusCode: 500})

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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