Commitfbc49132Recorded29 Mar 2026Repositorysigil-twitch

Simplify check-twitch-response/raw

Message

Delegate both the no-response guard and error handling to check-twitch-response instead of duplicating the guard logic.

Changed
 src/twitch.sgl | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Diff
src/twitch.sglmodified
@@ -151,14 +151,10 @@
151
;;; Check an HTTP response for errors and return the raw body string.
152
;;; Unlike check-twitch-response, returns unparsed body on success.
153
(define (check-twitch-response/raw response)
154
(if (not (http-response? response))
155
(error "Twitch API request failed: no response"))
156
(let ((status (http-response-status response))
157
(body (http-response-body response)))
158
(if (>= status 400)
159
;; Delegate to standard checker for error handling
160
(check-twitch-response response)
161
body)))
+154
(if (or (not (http-response? response))
+155
(>= (http-response-status response) 400))
+156
(check-twitch-response response)
+157
(http-response-body response)))
158
159
;;; Authenticated JSON GET request.
160
(define (twitch-get/json client url)