2020-10-19 23:13:18 +08:00
|
|
|
package errorx
|
|
|
|
|
2021-02-19 10:08:38 +08:00
|
|
|
// Chain runs funs one by one until an error occurred.
|
2020-10-19 23:13:18 +08:00
|
|
|
func Chain(fns ...func() error) error {
|
|
|
|
for _, fn := range fns {
|
|
|
|
if err := fn(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|