You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# `json_errors` provides a simple error handling for your REST applications. [](https://pkg.go.dev/github.com/pchchv/json_errors)[](https://goreportcard.com/report/github.com/pchchv/json_errors)
2
2
3
-
## Features
3
+
## Features:
4
4
5
5
* Compatible with built-in `error` interface
6
6
* Error wrapping
7
7
* JSON escaping
8
8
9
+
#
10
+
11
+
## Installation:
12
+
13
+
```bash
14
+
go get github.com/pchchv/json_errors
15
+
```
16
+
17
+
#
18
+
19
+
## Usage:
20
+
21
+
```go
22
+
package main
23
+
24
+
import (
25
+
"fmt"
26
+
27
+
"github.com/pchchv/json_errors"
28
+
)
29
+
30
+
funcsomeFunc() error {
31
+
return json_errors.New("nope")
32
+
}
33
+
34
+
funcmain() {
35
+
iferr:=someFunc(); err != nil {
36
+
wrapped:= json_errors.Wrap(err, "Message about error")
37
+
fmt.Println(wrapped.Error())
38
+
}
39
+
}
40
+
```
41
+
42
+
```bash
43
+
go run main.go
44
+
```
45
+
46
+
### Output:
47
+
48
+
```json
49
+
{"message":"Message about error","details":{"message":"nope"}}
0 commit comments