Skip to content

Commit 7663837

Browse files
committed
Add usage instructions
1 parent 1825870 commit 7663837

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
11
# `json_errors` provides a simple error handling for your REST applications. [![PkgGoDev](https://pkg.go.dev/badge/github.com/pchchv/json_errors)](https://pkg.go.dev/github.com/pchchv/json_errors) [![Go Report Card](https://goreportcard.com/badge/github.com/pchchv/json_errors)](https://goreportcard.com/report/github.com/pchchv/json_errors)
22

3-
## Features
3+
## Features:
44

55
* Compatible with built-in `error` interface
66
* Error wrapping
77
* JSON escaping
88

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+
func someFunc() error {
31+
return json_errors.New("nope")
32+
}
33+
34+
func main() {
35+
if err := 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"}}
50+
```
51+
52+
### See [examples](examples) for more.
53+
954
#

0 commit comments

Comments
 (0)