callchain.go 204 B

123456789101112
  1. package errorx
  2. // Chain runs funs one by one until an error occurred.
  3. func Chain(fns ...func() error) error {
  4. for _, fn := range fns {
  5. if err := fn(); err != nil {
  6. return err
  7. }
  8. }
  9. return nil
  10. }