open-nomad/client/allocrunner/taskrunner/getter/error.go
2023-04-10 15:36:59 +00:00

41 lines
699 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package getter
// Error is a RecoverableError used to include the URL along with the underlying
// fetching error.
type Error struct {
URL string
Err error
Recoverable bool
}
func (e *Error) Error() string {
if e == nil || e.Err == nil {
return "<nil>"
}
return e.Err.Error()
}
func (e *Error) IsRecoverable() bool {
return e.Recoverable
}
func (e *Error) Equal(o *Error) bool {
if e == nil || o == nil {
return e == o
}
switch {
case e.URL != o.URL:
return false
case e.Recoverable != o.Recoverable:
return false
case e.Error() != o.Error():
return false
default:
return true
}
}