diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-13 10:55:05 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-13 10:55:05 -0400 |
| commit | 66ef9438a3489bf8a0b80bb44e320c85261a6658 (patch) | |
| tree | 3a6a7e3e9923cb69d410cf7e2b45e0cafbe7300c /lulu.go | |
| parent | 56523fc6a304c09f252449342b10c52f7836c4aa (diff) | |
| download | lulu-66ef9438a3489bf8a0b80bb44e320c85261a6658.zip | |
GetPrintJobs(): stop when next page is nil
Diffstat (limited to 'lulu.go')
| -rw-r--r-- | lulu.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -189,6 +189,8 @@ func (c *Client) GetPrintJobs(queries ...PrintJobQuery) ([]PrintJob, error) { resp := v.(*getPrintJobsResp) if int(resp.Count) != len(resp.Results) { return fmt.Errorf("count (%d) != len(results) (%d)", resp.Count, len(resp.Results)) + } else if len(resp.Results) == 0 && resp.Next != "" { + return fmt.Errorf("no results on this page, but server returned a next page: %s", resp.Next) } return nil } @@ -202,7 +204,8 @@ func (c *Client) GetPrintJobs(queries ...PrintJobQuery) ([]PrintJob, error) { } if len(resp.Results) > 0 { jobs = append(jobs, resp.Results...) - } else { + } + if len(resp.Results) == 0 || len(resp.Next) == 0 { return jobs, nil } } |