35 lines
805 B
Go
35 lines
805 B
Go
/*
|
|
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
|