Sha256: 9e35e341529fd4e083b2afd2d7fd85557995e3bc4cce1f87d7e6e1bf6caba112

Contents?: true

Size: 897 Bytes

Versions: 27

Compression:

Stored size: 897 Bytes

Contents

# *Flexirest:* HTTP/parse error handling

Sometimes the backend server may respond with a non-200/304 header, in which case the code will raise an `Flexirest::HTTPClientException` for 4xx errors or an `Flexirest::HTTPServerException` for 5xx errors. These both have a `status` accessor and a `result` accessor (for getting access to the parsed body):

```ruby
begin
  Person.all
rescue Flexirest::HTTPClientException, Flexirest::HTTPServerException => e
  Rails.logger.error("API returned #{e.status} : #{e.result.message}")
end
```

If the response is unparsable (e.g. not in the desired content type), then it will raise an `Flexirest::ResponseParseException` which has a `status` accessor for the HTTP status code and a `body` accessor for the unparsed response body.

-----

[< Updating only changed/dirty attributes](updating-only-changed-dirty-attributes.md) | [Validation >](validation.md)

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
flexirest-1.9.12 docs/httpparse-error-handling.md
flexirest-1.9.11 docs/httpparse-error-handling.md
flexirest-1.9.10 docs/httpparse-error-handling.md
flexirest-1.8.9 docs/httpparse-error-handling.md
flexirest-1.8.8 docs/httpparse-error-handling.md
flexirest-1.8.7 docs/httpparse-error-handling.md
flexirest-1.8.6 docs/httpparse-error-handling.md
flexirest-1.8.5 docs/httpparse-error-handling.md
flexirest-1.8.4 docs/httpparse-error-handling.md
flexirest-1.8.3 docs/httpparse-error-handling.md
flexirest-1.8.2 docs/httpparse-error-handling.md
flexirest-1.8.1 docs/httpparse-error-handling.md
flexirest-1.8.0 docs/httpparse-error-handling.md
flexirest-1.7.9 docs/httpparse-error-handling.md
flexirest-1.7.8 docs/httpparse-error-handling.md
flexirest-1.7.7 docs/httpparse-error-handling.md
flexirest-1.7.6 docs/httpparse-error-handling.md
flexirest-1.7.5 docs/httpparse-error-handling.md
flexirest-1.7.4 docs/httpparse-error-handling.md
flexirest-1.7.3 docs/httpparse-error-handling.md