diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-12 16:45:00 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-12 16:45:00 -0400 |
| commit | 520f392ca5207f5364bbed501615613e3485b84b (patch) | |
| tree | 9f569676ef804f145935d9540f156d949e67e759 /err.go | |
| parent | 9010ebe8a581fb9db7bc6e97d40ff062fb18495f (diff) | |
| download | lulu-520f392ca5207f5364bbed501615613e3485b84b.zip | |
implement GET /print-jobs
Diffstat (limited to 'err.go')
| -rw-r--r-- | err.go | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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) +} |