Skip to content

Commit 8088208

Browse files
committed
Added GHA workflow
1 parent 4116352 commit 8088208

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

.github/workflows/test.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
pull_request:
9+
branches:
10+
- master
11+
- main
12+
13+
jobs:
14+
test:
15+
name: test
16+
strategy:
17+
matrix:
18+
go-version:
19+
- 1.19.x
20+
os: [ ubuntu-latest ]
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@master
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v3
28+
with:
29+
go-version: ${{ matrix.go-version }}
30+
cache: true # caching and restoring go modules and build outputs
31+
32+
- run: go env
33+
34+
- name: Install deps
35+
run: go mod download
36+
37+
- name: Test
38+
run: go test -v -race -p 1 ./...

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ A modern error handling package to add additional structured fields to errors. T
33
[only handle errors once rule](https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully) while not losing context where the error occurred.
44

55
* `errors.Wrap(err, "while reading")` includes a stack trace so logging can report the exact location where
6-
the error occurred. (you can also call `Wrapf()`)
6+
the error occurred. *You can also call `Wrapf()`*
77
* `errors.WithStack(err)` for when you don't need a message, just a stack trace to where the error occurred.
88
* `errors.WithFields{"fileName": fileName}.Wrap(err, "while reading")` Attach additional fields to the error and a stack
9-
trace to give structured logging as much context to the error as possible. (you can also call `Wrapf()`)
9+
trace to give structured logging as much context to the error as possible. *You can also call `Wrapf()`*
1010
* `errors.WithFields{"fileName": fileName}.WithStack(err)` for when you don't need a message, just a stack
1111
trace and some fields attached.
1212
* `errors.WithFields{"fileName": fileName}.Error("while reading")` when you want to create a string error with
13-
some fields attached. (you can also call `Errorf()`)
13+
some fields attached. *You can also call `Errorf()`*
1414

1515
### Extract structured data from wrapped errors
1616
Convenience functions to extract all stack and field information from the error.
@@ -43,6 +43,10 @@ If you are working at mailgun and are using scaffold; using `logrus.WithError(er
4343
automatically retrieve the fields attached to the error and index them into our logging system as separate
4444
searchable fields.
4545

46+
## Perfect for passing additional information to http handler middleware
47+
If you have custom http middleware for handling unhandled errors, this is an excellent way
48+
to easily pass additional information about the request up to the error handling middleware.
49+
4650
## Adding structured fields to an error
4751
Wraps the original error while providing structured field data
4852
```go

0 commit comments

Comments
 (0)