/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
go/updater/util/error.go
40 строк
840 B
Mike Maxim
merge go-updater repo into client (#26126)
05 янв 2024, 20:18
Не верифицирован
05 янв 2024, 20:18
75026c7
Код
Авторство
О чём код?
// Copyright 2015 Keybase, Inc. All rights reserved. Use of // this source code is governed by the included BSD license. package util import ( "fmt" "strings" ) // removeNilErrors returns error slice with nil errors removed func removeNilErrors(errs []error) []error { if len(errs) == 0 { return nil } var r []error for _, err := range errs { if err != nil { r = append(r, err) } } return r } // CombineErrors returns a single error for multiple errors, or nil if none func CombineErrors(errs ...error) error { errs = removeNilErrors(errs) if len(errs) == 0 { return nil } else if len(errs) == 1 { return errs[0] } // Combine multiple errors msgs := []string{} for _, err := range errs { msgs = append(msgs, err.Error()) } return fmt.Errorf("There were multiple errors: %s", strings.Join(msgs, "; ")) }