github.com/ansel1/merry (go): Package merry provides enriched golang errors, with stacktraces  merry creates errors with stacktraces, and can augment those errors with additional information.  When you create a new merry error, or wrap an existing error in a merry error, merry attaches a stacktrace to the error:  err has a stacktrace attached.  Alternately, you can wrap existing errors.  merry will attach a stacktrace at the point of wrapping:  Capturing the stack can be globally disabled with `SetStackCaptureEnabled(false)`.  Wrapping is idempotent: Wrap will only attach a stacktrace if the error doesn't already have one.  Wrap() is the simplest way to attach a stacktrace to an error, but other functions can be used instead, with both add a stacktrace, and augment or modify the error.  For example, Prepend() modifies the error's message (and also attaches a stacktrace):  See the other package functions for other ways to augment or modify errors, such as Append, WithUserMessage, WithHTTPCode, WithValue, etc.  These functions all return a merry.Error interface, which has methods which mirror the package level functions, to allow simple chaining:  Wrap will not take a new stacktrace if an error already has one attached.  Here will create a new error which replaces the stacktrace with a new one:  The go idiom of exporting package-level error variables for comparison to errors returned by the package is broken by merry.  For example:  If the error returned was a merry error, the equality comparison would always fail, because merry augments errors by wrapping them in layers.  To compensate for this, merry has the Is() function.  Is() will unwrap the err and compare each layer to the second argument.  You can add a cause to an error:  Cause(error) will return the cause of the argument.  RootCause(error) returns the innermost cause. Is(err1, err2) is cause aware, and will return true if err2 is a cause (anywhere in the causal change) of err1.  To obtain an error's stacktrace, call Stack().  To get other information about the site of the error, or print the error's stacktrace, see Location(), SourceLine(), Stacktrace(), and Details().  merry errors also implement the fmt.Formatter interface.  errors support the following fmt flags:
Keywords: errors|golang