53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
package errhttp
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
var _ Error = internalNotAcceptable{}
|
|
var _ ClientError = internalNotAcceptable{}
|
|
var _ NotAcceptable = internalNotAcceptable{}
|
|
|
|
var ClientErrorNotAcceptable ClientError = NotAcceptableWrap(nil).(NotAcceptable)
|
|
var ErrHTTPNotAcceptable Error = ClientErrorNotAcceptable
|
|
var ErrNotAcceptable error = ClientErrorNotAcceptable
|
|
|
|
type NotAcceptable interface {
|
|
ClientError
|
|
NotAcceptable()
|
|
}
|
|
|
|
type internalNotAcceptable struct {
|
|
err error
|
|
}
|
|
|
|
func NotAcceptableWrap(err error) error {
|
|
return internalNotAcceptable{
|
|
err:err,
|
|
}
|
|
}
|
|
|
|
func (receiver internalNotAcceptable) Error() string {
|
|
err := receiver.err
|
|
if nil == err {
|
|
return http.StatusText(receiver.ErrHTTP())
|
|
}
|
|
return receiver.err.Error()
|
|
}
|
|
|
|
func (internalNotAcceptable) ErrHTTP() int {
|
|
return http.StatusNotAcceptable
|
|
}
|
|
|
|
func (internalNotAcceptable) ClientError() {
|
|
// Nothing here.
|
|
}
|
|
|
|
func (internalNotAcceptable) NotAcceptable() {
|
|
// Nothing here.
|
|
}
|
|
|
|
func (receiver internalNotAcceptable) Unwrap() error {
|
|
return receiver.err
|
|
}
|