4 Exception handling
(require (planet gh/aws:1:=1/exn)) |
struct
(struct exn:fail:aws (http-code http-message aws-code aws-message) #:extra-constructor-name make-exn:fail:aws) http-code : exact-positive-integer? http-message : string? aws-code : string? aws-message : string?
Used by header&response->exn:fail:aws and check-response.
procedure
(header&response->exn:fail:aws headers entity ccm) → exn:fail:aws? headers : string? entity : (or/c bytes? xexpr?) ccm : continuation-mark-set?
Given an HTTP response’s headers and entity, return a
exn:fail:aws constructed with information from the response.
procedure
(check-response in headers)
→ (or/c string? (raise/c exn:fail:aws?)) in : input-port? headers : string?
Convenience: Given an input-port? and response headers as a
string? check the headers. Unless HTTP the status code is one of 200,
206, 301, 302, or 307, read the XML response body from the port and raise an
exn:fail:aws constructed with information from the reponse.
Otherwise, return headers and the caller may read the response entity
from in.
Note: This does not close the input port in before raising an
exception. It assumes you are using call/requests,
call/input-request, or call/output-request from the
http/request library (or using dynamic-wind or other
exception handling, or a custodian—