go-errhttp/lengthrequired.go

53 lines
1.1 KiB
Go
Raw Permalink Normal View History

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