README.md in pdfmonkey-0.1.0 vs README.md in pdfmonkey-0.2.0
- old
+ new
@@ -102,9 +102,31 @@
"updated_at": "2020-01-02T03:04:15.000+01:00"
}
}'
```
+#### Error handling
+
+In case of error, be it an HTTP layer error or an API error, `document.status` will be set to `'error'` and `document.error` will contain the error message.
+
+```ruby
+# Using an unknown template
+
+tempalte_id = 'unknown'
+data = { name: 'John Doe' }
+
+document = Pdfmonkey::Document.generate(template_id, data)
+
+document.status # => 'error'
+document.errors # => ["Couldn't find DocumentTemplate with 'id'=unknown"]
+
+# If the network is down
+document = Pdfmonkey::Document.generate(template_id, data)
+
+document.status # => 'error'
+document.errors # => ["Failed to open TCP connection to api.pdfmonkey.io:443 (getaddrinfo: nodename nor servname provided, or not known)"]
+```
+
## Development
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).