2023-08-14 13:56:09 +00:00
|
|
|
package errhttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ Error = internalMisdirectedRequest{}
|
|
|
|
var _ ClientError = internalMisdirectedRequest{}
|
|
|
|
var _ MisdirectedRequest = internalMisdirectedRequest{}
|
|
|
|
|
2023-10-18 05:32:39 +00:00
|
|
|
var ClientErrorMisdirectedRequest ClientError = MisdirectedRequestWrap(nil).(MisdirectedRequest)
|
|
|
|
var ErrHTTPMisdirectedRequest Error = ClientErrorMisdirectedRequest
|
|
|
|
var ErrMisdirectedRequest error = ClientErrorMisdirectedRequest
|
2023-08-14 13:56:09 +00:00
|
|
|
|
|
|
|
type MisdirectedRequest interface {
|
|
|
|
ClientError
|
|
|
|
MisdirectedRequest()
|
|
|
|
}
|
|
|
|
|
|
|
|
type internalMisdirectedRequest struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func MisdirectedRequestWrap(err error) error {
|
|
|
|
return internalMisdirectedRequest{
|
|
|
|
err:err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (receiver internalMisdirectedRequest) 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 (internalMisdirectedRequest) ErrHTTP() int {
|
|
|
|
return http.StatusMisdirectedRequest
|
|
|
|
}
|
|
|
|
|
|
|
|
func (internalMisdirectedRequest) ClientError() {
|
|
|
|
// Nothing here.
|
|
|
|
}
|
|
|
|
|
|
|
|
func (internalMisdirectedRequest) MisdirectedRequest() {
|
|
|
|
// Nothing here.
|
|
|
|
}
|
|
|
|
|
|
|
|
func (receiver internalMisdirectedRequest) Unwrap() error {
|
|
|
|
return receiver.err
|
|
|
|
}
|