Skip to content
Everything has a reason.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
context.go
karma.go
karma_benchmark_test.go
karma_test.go
reflect.go
reflect_test.go

README.md

Contexts

karma has contexts support, which allows to add arbitrary key-value fields to the error to ease debug.

Simplest usage is to add key-values for existing error:

func bar(arg string) error {
    return fmt.Errorf("arg is invalid: %s", arg)
}

func foo(arg string) error {
    err := bar(arg)
    if err != nil {
        return karma.Describe("method", "bar").Reason(err)
    }
}

fmt.Println(foo("hello"))

// Output:
//
// arg is invalid: hello
// └─ method: bar

Comparison

Feature karma errors emperror
Nested Errors
Key-Value Context ~
Descriptive Pretty Print
Embedded Stack Trace
JSON Friendly
Multi-error Support ~
Fluid Interface

License

This project is licensed under the terms of the MIT license.

You can’t perform that action at this time.