aboutsummaryrefslogtreecommitdiff
path: root/sx-request.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-11-08 16:54:51 -0500
committerSean Allred <code@seanallred.com>2014-11-08 16:54:51 -0500
commitb8da42344ebe3f380bb6f615c2ab13bb12c24876 (patch)
treeecd6ca63b45a47a7bdbd64fa461d883e2bceb0b6 /sx-request.el
parent6aa21b85ace92b01676c6da66372b409fe639920 (diff)
Use macro
Diffstat (limited to 'sx-request.el')
-rw-r--r--sx-request.el22
1 files changed, 10 insertions, 12 deletions
diff --git a/sx-request.el b/sx-request.el
index f987d2c..4e2ba5c 100644
--- a/sx-request.el
+++ b/sx-request.el
@@ -112,18 +112,16 @@ number of requests left every time it finishes a call.")
(sx-message "Unable to parse response: %S" response)
(error "Response could not be read by `json-read-from-string'")))
;; If we get here, the response is a valid data structure
- (when (assoc 'error_id response)
- (error "Request failed: (%s) [%i %s] %S"
- method
- (cdr (assoc 'error_id response))
- (cdr (assoc 'error_name response))
- (cdr (assoc 'error_message response))))
- (when (< (setq sx-request-remaining-api-requests
- (cdr (assoc 'quota_remaining response)))
- sx-request-remaining-api-requests-message-threshold)
- (sx-message "%d API requests reamining"
- sx-request-remaining-api-requests))
- (cdr (assoc 'items response))))))))
+ (sx-assoc-let response
+ (when error_id
+ (error "Request failed: (%s) [%i %s] %S"
+ method error_id error_name error_message))
+ (when (< (setq sx-request-remaining-api-requests
+ quota_remaining)
+ sx-request-remaining-api-requests-message-threshold)
+ (sx-message "%d API requests reamining"
+ sx-request-remaining-api-requests))
+ items)))))))
;;; Support Functions