json_errors provides a simple error handling for your REST applications.

Features:
- Compatible with built-in
error interface
- Error wrapping
- JSON escaping
Installation:
go get github.com/pchchv/json_errors
Usage:
package main
import (
"fmt"
"github.com/pchchv/json_errors"
)
func someFunc() error {
return json_errors.New("nope")
}
func main() {
if err := someFunc(); err != nil {
wrapped := json_errors.Wrap(err, "Message about error")
fmt.Println(wrapped.Error())
}
}
go run main.go
Output:
{"message":"Message about error","details":{"message":"nope"}}