initial commit
This commit is contained in:
34
doc.go
Normal file
34
doc.go
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Package adverr implements errors with call stack traces
|
||||
as well as error templates for error equality
|
||||
|
||||
Usage examples
|
||||
|
||||
Creating templates:
|
||||
var (
|
||||
ErrDoStuffFailed = adverr.NewErrTmpl("ErrDoStuffFailed", "Could'nt do stuff because of %s")
|
||||
)
|
||||
|
||||
Creating independent error (without error template):
|
||||
func doStuffWithIndependentErr() error {
|
||||
return adverr.New("Could'nt do stuff")
|
||||
}
|
||||
|
||||
Creating error based on template:
|
||||
func doStuff() error {
|
||||
return ErrDoStuffFailed.New("reasons")
|
||||
}
|
||||
|
||||
Printing errors on stderr convieniently:
|
||||
Print(myErr)
|
||||
Println(myErr)
|
||||
|
||||
Printing errors on stderr and exit with exitcode:
|
||||
Fatal(myErr, 1)
|
||||
Fatalln(myErr, 1)
|
||||
|
||||
Advantages of error templates
|
||||
two errors made by the same template will return true when called with errors.Is()
|
||||
|
||||
*/
|
||||
package adverr
|
Reference in New Issue
Block a user