From 520f392ca5207f5364bbed501615613e3485b84b Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 12 May 2026 16:45:00 -0400 Subject: implement GET /print-jobs --- err.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'err.go') diff --git a/err.go b/err.go index 58984dc..30c7f8f 100644 --- a/err.go +++ b/err.go @@ -18,6 +18,7 @@ func pkgErrf(err error, format string, a ...any) error { err) } +// error encoding request type errEncReq struct { payload any path string @@ -28,17 +29,19 @@ func (e errEncReq) Error() string { return fmt.Sprintf("error encoding request body %v for %s: %v", e.payload, e.path, e.error) } -type errResp struct { +// server responded with the wrong status +type errRespStatus struct { *http.Response } -func (e errResp) Error() string { +func (e errRespStatus) Error() string { resp := e.Response req := resp.Request body, _ := io.ReadAll(resp.Body) return fmt.Sprintf("%s %s: %s: %s", req.Method, req.URL, resp.Status, body) } +// error reading response type errReadResp struct { *http.Response error @@ -50,6 +53,7 @@ func (e errReadResp) Error() string { req.Method, req.URL, e.error) } +// error decoding response type errDecResp struct { *http.Response body []byte @@ -61,3 +65,14 @@ func (e errDecResp) Error() string { return fmt.Sprintf("%s %s: error decoding response body `%s`: %v", req.Method, req.URL, string(e.body), e.error) } + +// server returned a bad response +type errResp struct { + *http.Response + error +} + +func (e errResp) Error() string { + req := e.Response.Request + return fmt.Sprintf("%s %s: bad response: %v", req.Method, req.URL, e.error) +} -- cgit v1.2.3