Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
default: check
PROJECT := github.com/juju/errors

check:
go test && go test -compiler gccgo
.PHONY: check-licence check-go check docs

check: check-licence check-go
go test $(PROJECT)/...

check-licence:
@(fgrep -rl "Licensed under the LGPLv3" --exclude *.s .;\
fgrep -rl "MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT" --exclude *.s .;\
find . -name "*.go") | sed -e 's,\./,,' | sort | uniq -u | \
xargs -I {} echo FAIL: licence missed: {}

check-go:
$(eval GOFMT := $(strip $(shell gofmt -l .| sed -e "s/^/ /g")))
@(if [ x$(GOFMT) != x"" ]; then \
echo go fmt is sad: $(GOFMT); \
exit 1; \
fi )
@(go tool vet -all -composites=false -copylocks=false .)

docs:
godoc2md github.com/juju/errors > README.md
sed -i 's|\[godoc-link-here\]|[![GoDoc](https://godoc.org/github.com/juju/errors?status.svg)](https://godoc.org/github.com/juju/errors)|' README.md


.PHONY: default check docs
172 changes: 168 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ For example:
}


## func BadRequestf
``` go
func BadRequestf(format string, args ...interface{}) error
```
BadRequestf returns an error which satisfies IsBadRequest().


## func Cause
``` go
func Cause(err error) error
Expand Down Expand Up @@ -202,6 +209,13 @@ For example:
return errors.Errorf("validation failed: %s", message)


## func Forbiddenf
``` go
func Forbiddenf(format string, args ...interface{}) error
```
Forbiddenf returns an error which satistifes IsForbidden()


## func IsAlreadyExists
``` go
func IsAlreadyExists(err error) bool
Expand All @@ -210,6 +224,38 @@ IsAlreadyExists reports whether the error was created with
AlreadyExistsf() or NewAlreadyExists().


## func IsBadRequest
``` go
func IsBadRequest(err error) bool
```
IsBadRequest reports whether err was created with BadRequestf() or
NewBadRequest().


## func IsForbidden
``` go
func IsForbidden(err error) bool
```
IsForbidden reports whether err was created with Forbiddenf() or
NewForbidden().


## func IsMethodNotAllowed
``` go
func IsMethodNotAllowed(err error) bool
```
IsMethodNotAllowed reports whether err was created with MethodNotAllowedf() or
NewMethodNotAllowed().


## func IsNotAssigned
``` go
func IsNotAssigned(err error) bool
```
IsNotAssigned reports whether err was created with NotAssignedf() or
NewNotAssigned().


## func IsNotFound
``` go
func IsNotFound(err error) bool
Expand All @@ -226,6 +272,14 @@ IsNotImplemented reports whether err was created with
NotImplementedf() or NewNotImplemented().


## func IsNotProvisioned
``` go
func IsNotProvisioned(err error) bool
```
IsNotProvisioned reports whether err was created with NotProvisionedf() or
NewNotProvisioned().


## func IsNotSupported
``` go
func IsNotSupported(err error) bool
Expand All @@ -250,6 +304,14 @@ IsUnauthorized reports whether err was created with Unauthorizedf() or
NewUnauthorized().


## func IsUserNotFound
``` go
func IsUserNotFound(err error) bool
```
IsUserNotFound reports whether err was created with UserNotFoundf() or
NewUserNotFound().


## func Mask
``` go
func Mask(other error) error
Expand All @@ -267,11 +329,18 @@ hides the underlying error type. The error string still contains the full
annotations. If you want to hide the annotations, call Wrap.


## func MethodNotAllowedf
``` go
func MethodNotAllowedf(format string, args ...interface{}) error
```
MethodNotAllowedf returns an error which satisfies IsMethodNotAllowed().


## func New
``` go
func New(message string) error
```
New is a drop in replacement for the standard libary errors module that records
New is a drop in replacement for the standard library errors module that records
the location that the error is created.

For example:
Expand All @@ -288,6 +357,38 @@ NewAlreadyExists returns an error which wraps err and satisfies
IsAlreadyExists().


## func NewBadRequest
``` go
func NewBadRequest(err error, msg string) error
```
NewBadRequest returns an error which wraps err that satisfies
IsBadRequest().


## func NewForbidden
``` go
func NewForbidden(err error, msg string) error
```
NewForbidden returns an error which wraps err that satisfies
IsForbidden().


## func NewMethodNotAllowed
``` go
func NewMethodNotAllowed(err error, msg string) error
```
NewMethodNotAllowed returns an error which wraps err that satisfies
IsMethodNotAllowed().


## func NewNotAssigned
``` go
func NewNotAssigned(err error, msg string) error
```
NewNotAssigned returns an error which wraps err that satisfies
IsNotAssigned().


## func NewNotFound
``` go
func NewNotFound(err error, msg string) error
Expand All @@ -304,6 +405,14 @@ NewNotImplemented returns an error which wraps err and satisfies
IsNotImplemented().


## func NewNotProvisioned
``` go
func NewNotProvisioned(err error, msg string) error
```
NewNotProvisioned returns an error which wraps err that satisfies
IsNotProvisioned().


## func NewNotSupported
``` go
func NewNotSupported(err error, msg string) error
Expand All @@ -327,6 +436,21 @@ NewUnauthorized returns an error which wraps err and satisfies
IsUnauthorized().


## func NewUserNotFound
``` go
func NewUserNotFound(err error, msg string) error
```
NewUserNotFound returns an error which wraps err and satisfies
IsUserNotFound().


## func NotAssignedf
``` go
func NotAssignedf(format string, args ...interface{}) error
```
NotAssignedf returns an error which satisfies IsNotAssigned().


## func NotFoundf
``` go
func NotFoundf(format string, args ...interface{}) error
Expand All @@ -341,6 +465,13 @@ func NotImplementedf(format string, args ...interface{}) error
NotImplementedf returns an error which satisfies IsNotImplemented().


## func NotProvisionedf
``` go
func NotProvisionedf(format string, args ...interface{}) error
```
NotProvisionedf returns an error which satisfies IsNotProvisioned().


## func NotSupportedf
``` go
func NotSupportedf(format string, args ...interface{}) error
Expand Down Expand Up @@ -378,11 +509,11 @@ func Unauthorizedf(format string, args ...interface{}) error
Unauthorizedf returns an error which satisfies IsUnauthorized().


## func Forbiddenf
## func UserNotFoundf
``` go
func Forbiddenf(format string, args ...interface{}) error
func UserNotFoundf(format string, args ...interface{}) error
```
Forbiddenf returns an error which satisfies IsForbidden().
UserNotFoundf returns an error which satisfies IsUserNotFound().


## func Wrap
Expand Down Expand Up @@ -460,6 +591,29 @@ For example:
}


### func NewErrWithCause
``` go
func NewErrWithCause(other error, format string, args ...interface{}) Err
```
NewErrWithCause is used to return an Err with case by other error for the purpose of embedding in other
structures. The location is not specified, and needs to be set with a call
to SetLocation.

For example:


type FooError struct {
errors.Err
code int
}

func (e *FooError) Annotate(format string, args ...interface{}) error {
err := &FooError{errors.NewErrWithCause(e.Err, format, args...), e.code}
err.SetLocation(1)
return err
})




### func (\*Err) Cause
Expand All @@ -483,6 +637,16 @@ Error implements error.Error.



### func (\*Err) Format
``` go
func (e *Err) Format(s fmt.State, verb rune)
```
Format implements fmt.Formatter
When printing errors with %+v it also prints the stack trace.
%#v unsurprisingly will print the real underlying type.



### func (\*Err) Location
``` go
func (e *Err) Location() (filename string, line int)
Expand Down
5 changes: 5 additions & 0 deletions dependencies.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
github.com/juju/loggo git 8232ab8918d91c72af1a9fb94d3edbe31d88b790 2017-06-05T01:46:07Z
github.com/juju/testing git 72703b1e95eb8ce4737fd8a3d8496c6b0be280a6 2018-05-17T13:41:05Z
gopkg.in/check.v1 git 4f90aeace3a26ad7021961c297b22c42160c7b25 2016-01-05T16:49:36Z
gopkg.in/mgo.v2 git f2b6f6c918c452ad107eec89615f074e3bd80e33 2016-08-18T01:52:18Z
gopkg.in/yaml.v2 git 1be3d31502d6eabc0dd7ce5b0daab022e14a5538 2017-07-12T05:45:46Z