November 2018
Intermediate to advanced
528 pages
13h 21m
English
Interestingly, Hyperledger Fabric has its own error-handling package, github.com/pkg/errors, which allows you to handle errors in a much better way than the built-in error handling provided by Go. For example:
import ( "fmt" "github.com/pkg/errors")//wrapping error with stackfunc wrapWithStack() error { err := displayError () return errors.Wrap(err, "wrapping an application error with stack trace")}func displayError() error { return errors.New("example error message")}func main() { err := displayError() fmt.Printf("print error without stack trace: %s\n\n", err) fmt.Printf("print error with stack trace: %+v\n\n", err) err = wrapWithStack() fmt.Printf("%+v\n\n", err)}
The aforementioned package provides several helpful ...
Read now
Unlock full access