go-errhttp/upgraderequired.go

51 lines
934 B
Go
Raw Normal View History

2017-02-06 20:58:13 +00:00
package errhttp
import (
"net/http"
)
var _ Error = internalUpgradeRequired{}
var _ ClientError = internalUpgradeRequired{}
var _ UpgradeRequired = internalUpgradeRequired{}
var ErrUpgradeRequired error = UpgradeRequiredWrap(nil)
2017-02-06 20:58:13 +00:00
type UpgradeRequired interface {
ClientError
UpgradeRequired()
}
type internalUpgradeRequired struct {
err error
}
func UpgradeRequiredWrap(err error) error {
return internalUpgradeRequired{
err:err,
}
}
func (receiver internalUpgradeRequired) 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 (internalUpgradeRequired) ErrHTTP() int {
return http.StatusUpgradeRequired
}
2017-02-06 20:58:13 +00:00
func (internalUpgradeRequired) ClientError() {
// Nothing here.
}
func (internalUpgradeRequired) UpgradeRequired() {
// Nothing here.
}
func (receiver internalUpgradeRequired) Unwrap() error {
return receiver.err
}