go-errhttp/gatewaytimeout.go

55 lines
1.1 KiB
Go
Raw Normal View History

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