Skip to content

Instantly share code, notes, and snippets.

@vadzappa
Created April 9, 2020 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadzappa/15bb6406d2da06d2b516af5a0295d123 to your computer and use it in GitHub Desktop.
Save vadzappa/15bb6406d2da06d2b516af5a0295d123 to your computer and use it in GitHub Desktop.
package controller
import (
"blodpost/logger"
"blodpost/protocol"
"github.com/pkg/errors"
"math/rand"
)
func Process(company *protocol.Company) error {
if err := doStuff(); err != nil {
// note the logging done here and company provided as an argument here
logger.Error("failed to process company", company)
return errors.Wrap(err, "failed to process")
}
return nil
}
func doStuff() error {
if rand.Int63n(10) < 5 {
return errors.New("random error")
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment