Home

Awesome

errstack

License: MIT Go Reference

A very small library to combine errors.

Furthermore, I want my errors to display the filename and line number.

pool.go:19="missing max value" users.go:25="missing password field"

Example

package main

import (
    "log"
)

func main() {
    // 1. Something bad happened at the beginning of your stack.
    e := errstack.New("password field is missing")

    // 2. And then the second error occured.
    e.Append("company name is missing")

    // 3. And then the third error occured.
    e.Append("username is too short")

    log.Println(e.Error())
    // The log will look like this:
    // /path/to/project.go:68="username is too short" /path/to/project.go:65="company name is missing" /path/to/project.go:15="password field is missing"
}

My other Go libraries