go-errhttp/notextended.go

53 lines
897 B
Go
Raw Normal View History

2017-02-06 21:14:15 +00:00
package errhttp
import (
"net/http"
)
var _ Error = internalNotExtended{}
var _ ServerError = internalNotExtended{}
var _ NotExtended = internalNotExtended{}
var ErrNotExtended error = NotExtendedWrap(nil)
2017-02-06 21:14:15 +00:00
type NotExtended interface {
ServerError
NotExtended()
}
var _ NotExtended = internalNotExtended{}
2017-02-06 21:14:15 +00:00
type internalNotExtended struct {
err error
}
func NotExtendedWrap(err error) error {
return internalNotExtended{
err:err,
}
}
func (receiver internalNotExtended) 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 21:14:15 +00:00
}
func (internalNotExtended) ErrHTTP() int {
return http.StatusNotExtended
}
2017-02-06 21:14:15 +00:00
func (internalNotExtended) ServerError() {
// Nothing here.
}
func (internalNotExtended) NotExtended() {
// Nothing here.
}
func (receiver internalNotExtended) Unwrap() error {
return receiver.err
}