2023-08-14 13:56:09 +00:00
|
|
|
package errhttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ Error = internalTooEarly{}
|
|
|
|
var _ ClientError = internalTooEarly{}
|
|
|
|
var _ TooEarly = internalTooEarly{}
|
|
|
|
|
2023-10-01 02:30:28 +00:00
|
|
|
var ErrTooEarly error = TooEarlyWrap(nil)
|
2023-08-14 13:56:09 +00:00
|
|
|
|
|
|
|
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()
|
2023-08-14 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|