go-errhttp/tooearly.go

53 lines
944 B
Go
Raw Normal View History

package errhttp
import (
"net/http"
)
var _ Error = internalTooEarly{}
var _ ClientError = internalTooEarly{}
var _ TooEarly = internalTooEarly{}
var ClientErrorTooEarly ClientError = TooEarlyWrap(nil).(TooEarly)
var ErrHTTPTooEarly Error = ClientErrorTooEarly
var ErrTooEarly error = ClientErrorTooEarly
type TooEarly interface {
ClientError
TooEarly()
}
type internalTooEarly struct {
err error
}
func TooEarlyWrap(err error) error {
return internalTooEarly{
err:err,
}
}
func (receiver internalTooEarly) Error() string {
2023-10-01 02:30:28 +00:00
err := receiver.err
if nil == err {
return http.StatusText(receiver.ErrHTTP())
}
return err.Error()
}
func (internalTooEarly) ErrHTTP() int {
return http.StatusTooEarly
}
func (internalTooEarly) ClientError() {
// Nothing here.
}
func (internalTooEarly) TooEarly() {
// Nothing here.
}
func (receiver internalTooEarly) Unwrap() error {
return receiver.err
}