Skip to content

docs: document error handling in the README - #64

Open
erimicel wants to merge 1 commit into
typesense:masterfrom
OLIOEX:docs-error-handling
Open

erimicel wants to merge 1 commit into
typesense:masterfrom
OLIOEX:docs-error-handling

Conversation

@erimicel

Copy link
Copy Markdown
Contributor

Adds an "Error handling" section to the README. This is the README part of #60, split out on its own.

It also corrects the example from #60. Errors are built with new(response: response), so e.data is a Hash and the Faraday response is at e.data[:response]. The #60 example called e.data.status, which raises NoMethodError.

Changes

  • How to read the message, HTTP status and body from a raised Typesense::Error.
  • Which exception class each status code maps to.
  • Network failures that exhaust retries are re-raised as the original Faraday/Errno exception, not as a Typesense::Error.

Verification

Ran the README example against master with a stubbed 404 response: e.message is "Not Found", e.data[:response].status is 404, and e.data[:response].body is the raw JSON body.

PR Checklist

Explain how to read the message, HTTP status and body from a raised Typesense::Error, which class each status code maps to, and that network errors are re-raised as-is once retries run out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant