https://github.com/karitham/httperr
http error handling simplified
https://github.com/karitham/httperr
error-handling golang http
Last synced: 2 months ago
JSON representation
http error handling simplified
- Host: GitHub
- URL: https://github.com/karitham/httperr
- Owner: karitham
- License: mit
- Created: 2021-05-06T08:53:13.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-06T09:08:31.000Z (about 4 years ago)
- Last Synced: 2025-01-22T05:29:47.145Z (4 months ago)
- Topics: error-handling, golang, http
- Language: Go
- Homepage: https://pkg.go.dev/github.com/Karitham/httperr
- Size: 1.95 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httperr
httperr is a simple interface for easily implementing errors in http responses.
It's as simple as calling JSON on a basic error.
```go
httperr.JSON(w,r,
&httperr.DefaultError{
Message: "There was an error retrieving the items",
ErrorCode: "GI0001",
StatusCode: 500,
},
)
```The default `DefaultError` changes the status code of the response on `Render`, then is marshalled.
This was inspired by [render](https://github.com/go-chi/render), but simplified and modified to fit the usual simple error handling