ooni-probe-cli/internal/engine/internal/sessionresolver/errwrapper.go
Simone Basso 034db78f94
refactor(sessionresolver): adapt to changing network conditions (#238)
* feat(sessionresolver): try many and use what works

* fix(sessionresolver): make sure we can use quic

* fix: the config struct is unnecessary

* fix: make kvstore optional

* feat: write simple integration test

* feat: start adding tests

* feat: continue writing tests

* fix(sessionresolver): add more unit tests

* fix(sessionresolver): finish adding tests

* refactor(sessionresolver): changes after code review
2021-03-03 11:28:39 +01:00

24 lines
482 B
Go

package sessionresolver
import (
"errors"
"fmt"
)
// errwrapper wraps an error to include the URL of the
// resolver that we're currently using.
type errwrapper struct {
error
URL string
}
// Error implements error.Error.
func (ew *errwrapper) Error() string {
return fmt.Sprintf("<%s> %s", ew.URL, ew.error.Error())
}
// Is allows consumers to query for the type of the underlying error.
func (ew *errwrapper) Is(target error) bool {
return errors.Is(ew.error, target)
}