Skip to content

Commit f0f0807

Browse files
committed
Update readme
1 parent 4e950ce commit f0f0807

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22

33
[![Latest Stable Version][ico-release]][link-release]
44
[![Build Status][ico-workflow]][link-workflow]
5+
[![Coverage Status][ico-coverage]][link-coverage]
6+
[![Quality Score][ico-code-quality]][link-code-quality]
7+
[![Go Report Card][ico-go-report-card]][link-go-report-card]
58
[![Go Dev Reference][ico-go-dev-reference]][link-go-dev-reference]
69
[![Software License][ico-license]][link-licence]
710

11+
**Multi error**: Concurrent safe representation of a list of errors as a single error.
12+
13+
**Data error**: Additional context for error using data fields and cause (previous) error.
14+
815

916
## Installation
1017

@@ -16,6 +23,46 @@ go get github.com/gravitton/errors
1623
## Usage
1724

1825
```go
26+
package main
27+
28+
import (
29+
"github.com/gravitton/errors"
30+
"sync"
31+
)
32+
33+
func Process() error {
34+
errs := errors.NewMulti()
35+
36+
if err := process1(); err != nil {
37+
errs.Append(err)
38+
}
39+
40+
if err := process2(); err != nil {
41+
errs.Append(err)
42+
}
43+
44+
return errs.ErrorOrNil()
45+
}
46+
47+
func ProcessConcurrent() error {
48+
errs := errors.NewMulti()
49+
wg := sync.WaitGroup{}
50+
51+
for i := 0; i < 10; i++ {
52+
wg.Add(1)
53+
go func(i int) {
54+
defer wg.Done()
55+
56+
if err := process(i); err != nil {
57+
errs.Append(errors.Wrap(err).WithField("process", i))
58+
}
59+
}(i)
60+
}
61+
62+
wg.Wait()
63+
64+
return errs.ErrorOrNil()
65+
}
1966
```
2067

2168

@@ -34,6 +81,9 @@ The MIT License (MIT). Please see [License File][link-licence] for more informat
3481
[ico-workflow]: https://img.shields.io/github/actions/workflow/status/gravitton/errors/main.yml?branch=main&style=flat-square
3582
[ico-release]: https://img.shields.io/github/v/release/gravitton/errors?style=flat-square&colorB=blue
3683
[ico-go-dev-reference]: https://img.shields.io/badge/go.dev-reference-blue?style=flat-square
84+
[ico-go-report-card]: https://goreportcard.com/badge/github.com/gravitton/errors?style=flat-square
85+
[ico-coverage]: https://img.shields.io/scrutinizer/coverage/g/gravitton/errors/main.svg?style=flat-square
86+
[ico-code-quality]: https://img.shields.io/scrutinizer/g/gravitton/errors.svg?style=flat-square
3787

3888
[link-author]: https://github.com/gravitton
3989
[link-release]: https://github.com/gravitton/errors/releases
@@ -42,3 +92,6 @@ The MIT License (MIT). Please see [License File][link-licence] for more informat
4292
[link-changelog]: ./CHANGELOG.md
4393
[link-workflow]: https://github.com/gravitton/errors/actions
4494
[link-go-dev-reference]: https://pkg.go.dev/github.com/gravitton/errors
95+
[link-go-report-card]: https://goreportcard.com/report/github.com/gravitton/errors
96+
[link-coverage]: https://scrutinizer-ci.com/g/gravitton/errors/code-structure
97+
[link-code-quality]: https://scrutinizer-ci.com/g/gravitton/errors

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/gravitton/errors
22

33
go 1.24
44

5-
require github.com/gravitton/assert v0.1.0
5+
require github.com/gravitton/assert v0.2.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github.com/gravitton/assert v0.1.0 h1:xHqkU70NLx/KOroQb6/PxeNefpBTghfxVvHTkwxxm10=
2-
github.com/gravitton/assert v0.1.0/go.mod h1:t/H52Szce7uofC0H1sN9yLZsj1TBvky5sGmrFiaxypY=
1+
github.com/gravitton/assert v0.2.0 h1:zJL3v5rHP/P1eJKljxFTb8zbW8WWr7Ih5wZBT/JMp80=
2+
github.com/gravitton/assert v0.2.0/go.mod h1:t/H52Szce7uofC0H1sN9yLZsj1TBvky5sGmrFiaxypY=

0 commit comments

Comments
 (0)