go-errhttp/faileddependency.go

51 lines
954 B
Go
Raw Normal View History

2017-02-06 20:58:13 +00:00
package errhttp
import (
"net/http"
)
var _ Error = internalFailedDependency{}
var _ ClientError = internalFailedDependency{}
var _ FailedDependency = internalFailedDependency{}
var ErrFailedDependency error = FailedDependencyWrap(nil)
2017-02-06 20:58:13 +00:00
type FailedDependency interface {
ClientError
FailedDependency()
}
type internalFailedDependency struct {
err error
}
func FailedDependencyWrap(err error) error {
return internalFailedDependency{
err:err,
}
}
func (receiver internalFailedDependency) Error() string {
2023-10-01 02:30:28 +00:00
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
2017-02-06 20:58:13 +00:00
}
func (internalFailedDependency) ErrHTTP() int {
return http.StatusFailedDependency
}
2017-02-06 20:58:13 +00:00
func (internalFailedDependency) ClientError() {
// Nothing here.
}
func (internalFailedDependency) FailedDependency() {
// Nothing here.
}
func (receiver internalFailedDependency) Unwrap() error {
return receiver.err
}