pki/vendor/github.com/go-acme/lego/v4/certificate/errors.go

41 lines
614 B
Go
Raw Normal View History

2020-11-25 20:36:07 +01:00
package certificate
import (
2023-10-01 12:07:22 +02:00
"errors"
2020-11-25 20:36:07 +01:00
"fmt"
)
2023-10-01 12:07:22 +02:00
type obtainError struct {
data map[string]error
}
func newObtainError() *obtainError {
return &obtainError{data: make(map[string]error)}
}
2020-11-25 20:36:07 +01:00
2023-10-01 12:07:22 +02:00
func (e *obtainError) Add(domain string, err error) {
e.data[domain] = err
}
2020-11-25 20:36:07 +01:00
2023-10-01 12:07:22 +02:00
func (e *obtainError) Join() error {
if e == nil {
return nil
2020-11-25 20:36:07 +01:00
}
2023-10-01 12:07:22 +02:00
if len(e.data) == 0 {
return nil
2020-11-25 20:36:07 +01:00
}
2023-10-01 12:07:22 +02: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)
2020-11-25 20:36:07 +01:00
}
type domainError struct {
Domain string
Error error
}