iperf3exporter/vendor/github.com/DisgoOrg/restclient/error.go
Marvin Preuss 2343c9588a
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
first commit
2021-10-20 10:08:56 +02:00

44 lines
940 B
Go

package restclient
import (
"net/http"
)
var _ RestError = (*restErrorImpl)(nil)
var _ error = (*restErrorImpl)(nil)
// RestError holds the http.Response & an error
type RestError interface {
error
Response() *http.Response
}
// NewError returns a new Error with the given http.Response & error
//goland:noinspection GoUnusedExportedFunction
func NewError(response *http.Response, err error) RestError {
return &restErrorImpl{
err: err,
response: response,
}
}
type restErrorImpl struct {
err error
response *http.Response
}
// Error returns the specific error message
func (r *restErrorImpl) Error() string {
return r.err.Error()
}
// Error returns the specific error message
func (r *restErrorImpl) String() string {
return r.err.Error()
}
// Response returns the http.Response. May be null depending on what broke during the request
func (r *restErrorImpl) Response() *http.Response {
return r.response
}