2019-03-11 16:56:48 +00:00
|
|
|
package certificate
|
2018-12-06 21:50:17 +00:00
|
|
|
|
|
|
|
import (
|
2023-08-19 16:05:33 +00:00
|
|
|
"errors"
|
2018-12-06 21:50:17 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2023-08-19 16:05:33 +00:00
|
|
|
type obtainError struct {
|
|
|
|
data map[string]error
|
|
|
|
}
|
|
|
|
|
|
|
|
func newObtainError() *obtainError {
|
|
|
|
return &obtainError{data: make(map[string]error)}
|
|
|
|
}
|
2018-12-06 21:50:17 +00:00
|
|
|
|
2023-08-19 16:05:33 +00:00
|
|
|
func (e *obtainError) Add(domain string, err error) {
|
|
|
|
e.data[domain] = err
|
|
|
|
}
|
2018-12-06 21:50:17 +00:00
|
|
|
|
2023-08-19 16:05:33 +00:00
|
|
|
func (e *obtainError) Join() error {
|
|
|
|
if e == nil {
|
|
|
|
return nil
|
2018-12-06 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-19 16:05:33 +00:00
|
|
|
if len(e.data) == 0 {
|
|
|
|
return nil
|
2018-12-06 21:50:17 +00:00
|
|
|
}
|
2023-08-19 16:05:33 +00:00
|
|
|
|
|
|
|
var err error
|
|
|
|
for d, e := range e.data {
|
|
|
|
err = errors.Join(err, fmt.Errorf("%s: %w", d, e))
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Errorf("error: one or more domains had a problem:\n%w", err)
|
2018-12-06 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type domainError struct {
|
|
|
|
Domain string
|
|
|
|
Error error
|
|
|
|
}
|