ubgo is in early alpha: libraries and APIs may still change.

Skip to content
ubgo Alpha

goerr

Error type with separate operator and user messages, error codes, key/value data and trace IDs.

go get github.com/ubgo/goerr
Language
Go
Go version
1.24
Core deps
0 direct
Latest tag
v0.1.0
License
Apache-2.0
Go modules
1

Code from the README

package main

import (
    "fmt"

    "github.com/ubgo/goerr"
)

func main() {
    err := goerr.New("db: deadlock detected on user_orders",
        goerr.WithMessageUser("Something went wrong, please retry"),
        goerr.WithCode("E_TX_RETRY"),
        goerr.WithTraceID("trace-abc123"),
        goerr.WithKV("table", "user_orders"),
    )

    fmt.Println(err.Error())             // operator-facing
    fmt.Println(err.ErrorUser().Error()) // user-facing
    fmt.Println(err.Response().ToJSON()) // wire payload
}

From the goerr README.