Skip to content

Commit

Permalink
Add travis and make
Browse files Browse the repository at this point in the history
  • Loading branch information
geek committed Jun 15, 2020
1 parent 2a60d2b commit f058e10
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 22 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: go
go_import_path: github.com/geek/herrors

go:
- 1.14.x
- tip

env:
global:
- GO111MODULE=on

script:
- make test
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PKG := github.com/geek/herrors

fmt:
@test -z "$(shell gofmt -s -l -d -e ./ | tee /dev/stderr)"

vet:
go vet $(PKG)

test: vet fmt
go test $(PKG)
6 changes: 0 additions & 6 deletions README → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ func handler(w http.ResponseWriter, r *http.Request) {

## Usage

The following errors are available

```go

```

#### func New

```go
Expand Down
56 changes: 41 additions & 15 deletions herrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,47 @@ import (
)

var (
ErrBadRequest = New(http.StatusBadRequest)
ErrUnauthorized = New(http.StatusUnauthorized)
ErrPaymentRequired = New(http.StatusPaymentRequired)
ErrForbidden = New(http.StatusForbidden)
ErrNotFound = New(http.StatusNotFound)
ErrMethodNotAllowed = New(http.StatusMethodNotAllowed)
ErrNotAcceptable = New(http.StatusNotAcceptable)
ErrProxyAuthRequired = New(http.StatusProxyAuthRequired)
ErrRequestTimeout = New(http.StatusRequestTimeout)
ErrConflict = New(http.StatusConflict)
ErrResourceGone = New(http.StatusGone)
ErrLengthRequired = New(http.StatusLengthRequired)
ErrPreconditionFailed = New(http.StatusPreconditionFailed)

ErrInternalServer = New(http.StatusInternalServerError)
// 4xx errors
ErrBadRequest = New(http.StatusBadRequest)
ErrUnauthorized = New(http.StatusUnauthorized)
ErrPaymentRequired = New(http.StatusPaymentRequired)
ErrForbidden = New(http.StatusForbidden)
ErrNotFound = New(http.StatusNotFound)
ErrMethodNotAllowed = New(http.StatusMethodNotAllowed)
ErrNotAcceptable = New(http.StatusNotAcceptable)
ErrProxyAuthRequired = New(http.StatusProxyAuthRequired)
ErrRequestTimeout = New(http.StatusRequestTimeout)
ErrConflict = New(http.StatusConflict)
ErrResourceGone = New(http.StatusGone)
ErrLengthRequired = New(http.StatusLengthRequired)
ErrPreconditionFailed = New(http.StatusPreconditionFailed)
ErrEntityTooLarge = New(http.StatusRequestEntityTooLarge)
ErrURITooLong = New(http.StatusRequestURITooLong)
ErrUnsupportedMediaType = New(http.StatusUnsupportedMediaType)
ErrRangeNotSatisfiable = New(http.StatusRequestedRangeNotSatisfiable)
ErrExpectationFailed = New(http.StatusExpectationFailed)
ErrMisdirectedRequest = New(http.StatusMisdirectedRequest)
ErrUnprocessableEntity = New(http.StatusUnprocessableEntity)
ErrLocked = New(http.StatusLocked)
ErrFailedDependency = New(http.StatusFailedDependency)
ErrTooEarly = New(http.StatusTooEarly)
ErrPreconditionRequired = New(http.StatusPreconditionRequired)
ErrTooManyRequests = New(http.StatusTooManyRequests)
ErrHeaderFieldsTooLarge = New(http.StatusRequestHeaderFieldsTooLarge)
ErrIllegal = New(http.StatusUnavailableForLegalReasons)

// 5xx errors
ErrInternalServer = New(http.StatusInternalServerError)
ErrNotImplemented = New(http.StatusNotImplemented)
ErrBadGateway = New(http.StatusBadGateway)
ErrServiceUnavailable = New(http.StatusServiceUnavailable)
ErrGatewayTimeout = New(http.StatusGatewayTimeout)
ErrHTTPVersionNotSupported = New(http.StatusHTTPVersionNotSupported)
ErrVariantAlsoNegotiates = New(http.StatusVariantAlsoNegotiates)
ErrInsufficientStorage = New(http.StatusInsufficientStorage)
ErrLoopDetected = New(http.StatusLoopDetected)
ErrNotExtended = New(http.StatusNotExtended)
ErrNetworkAuthenticationRequired = New(http.StatusNetworkAuthenticationRequired)
)

// New constructs an ErrHttp error with the code and message populated
Expand Down
2 changes: 1 addition & 1 deletion herrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestErrorWrapUnwrap(t *testing.T) {
}
}

func TestfmtErrorfWrap(t *testing.T) {
func TestFmtErrorfWrap(t *testing.T) {
w := fmt.Errorf("foo %w", ErrBadRequest)

type hasCode interface {
Expand Down

0 comments on commit f058e10

Please sign in to comment.