Skip to content

Commit

Permalink
Added GHA workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Jan 26, 2023
1 parent 4116352 commit 8088208
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
test:
name: test
strategy:
matrix:
go-version:
- 1.19.x
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true # caching and restoring go modules and build outputs

- run: go env

- name: Install deps
run: go mod download

- name: Test
run: go test -v -race -p 1 ./...
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ A modern error handling package to add additional structured fields to errors. T
[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.

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

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

## Perfect for passing additional information to http handler middleware
If you have custom http middleware for handling unhandled errors, this is an excellent way
to easily pass additional information about the request up to the error handling middleware.

## Adding structured fields to an error
Wraps the original error while providing structured field data
```go
Expand Down

0 comments on commit 8088208

Please sign in to comment.