initial commit

This commit is contained in:
Timon Ringwald
2020-09-09 11:48:46 +02:00
commit 4e5775fcfa
8 changed files with 292 additions and 0 deletions

34
doc.go Normal file
View 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