Created
April 9, 2020 09:41
-
-
Save vadzappa/15bb6406d2da06d2b516af5a0295d123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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