@@ -291,7 +291,6 @@ This produces.
291291
292292A full example of paging is provided below.
293293
294-
295294### Exceptions
296295
297296The library will raise ** CloudFlareAPIError** when the API call fails.
@@ -331,6 +330,38 @@ import CloudFlare.exceptions
331330 ...
332331```
333332
333+ ### Exception examples
334+
335+ Here's examples using the CLI command cli4 of the responses passed back in exceptions.
336+
337+ First a simple get with a clean (non-error) response.
338+
339+ ```
340+ $ cli4 /zones/:example.com/dns_records | jq -c '.[]|{"name":.name,"type":.type,"content":.content}'
341+ {"name":"example.com","type":"MX","content":"something.example.com"}
342+ {"name":"something.example.com","type":"A","content":"10.10.10.10"}
343+ $
344+ ```
345+
346+ Next a simple/single error response.
347+ This is simulated by providing incorrect authentication information.
348+
349+ ```
350+ $ CF_API_EMAIL='someone@example.com' cli4 /zones/
351+ cli4: /zones - 9103 Unknown X-Auth-Key or X-Auth-Email
352+ $
353+ ```
354+
355+ Finally, a command that provides more than one error response.
356+ This is simulated by passing an invalid IPv4 address to a DNS record creation.
357+
358+ ```
359+ $ cli4 --post name='foo' type=A content="1" /zones/:example.com/dns_records
360+ cli4: /zones/:mahtin.net/dns_records - 9005 Content for A record is invalid. Must be a valid IPv4 address
361+ cli4: /zones/:mahtin.net/dns_records - 1004 DNS Validation Error
362+ $
363+ ```
364+
334365## Included example code
335366
336367The [ examples] ( https://github.com/cloudflare/python-cloudflare/tree/master/examples ) folder contains many examples in both simple and verbose formats.
0 commit comments