On this page:
exn: fail: aws
header&response->exn: fail: aws
check-response

4 Exception handling

Most of the functions do not return a failure value. Instead they raise exn:fail:aws, which you need to “catch” using with-handlers.

 (require (planet gh/aws:1:=4/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?

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?
Check headers. If the status code is one of 200, 201, 202, 204, 206, 301, 302, or 307, simply return headers (without reading any response entity from in).

Otherwise, read the XML response body from in and use the information to construct and raise exn:fail:aws.

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—or whatever) to make sure the port is closed!