Class: RestClient::Exception

### Home Classes Methods

### In Files

- lib/restclient/exceptions.rb

### Parent

RuntimeError

### Methods

- ::new
- #http_body
- #http_code
- #inspect
- #message
- #to_s

### Class/Module Index

Quicksearch

- RestClient
- RestClient::AbstractResponse
- RestClient::Exception
- RestClient::ExceptionWithResponse
- RestClient::Exceptions
- RestClient::MaxRedirectsReached
- RestClient::Payload
- RestClient::Payload::Base
- RestClient::Payload::Multipart
- RestClient::Payload::Streamed
- RestClient::Payload::UrlEncoded
- RestClient::Platform
- RestClient::RawResponse
- RestClient::Redirect
- RestClient::Request
- RestClient::Request::Redirect
- RestClient::Request::RequestFailed
- RestClient::RequestFailed
- RestClient::Resource
- RestClient::Response
- RestClient::ResponseForException
- RestClient::SSLCertificateNotVerified
- RestClient::ServerBrokeConnection
- RestClient::Windows
- RestClient::Windows::RootCerts
- RestClient::Windows::RootCerts::CERT_CONTEXT

No matching classes.

# RestClient::Exception

This is the base RestClient exception class. Rescue it if you want to catch any exception that your request might raise You can get the status code by e.http_code, or see anything about the response via e.response. For example, the entire result body (which is probably an HTML error page) is e.response.

### Attributes

message[W]
response[RW]

### Public Class Methods

new(response = nil, initial_response_code = nil) click to toggle source

    # File lib/restclient/exceptions.rb, line 91
    def initialize response = nil, initial_response_code = nil
      @response = response
      @message = nil
      @initial_response_code = initial_response_code

      # compatibility: this make the exception behave like a Net::HTTPResponse
      response.extend ResponseForException if response
    end

### Public Instance Methods

http_body() click to toggle source

    # File lib/restclient/exceptions.rb, line 109
    def http_body
      @response.body if @response
    end

http_code() click to toggle source

    # File lib/restclient/exceptions.rb, line 100
    def http_code
      # return integer for compatibility
      if @response
        @response.code.to_i
      else
        @initial_response_code
      end
    end

inspect() click to toggle source

    # File lib/restclient/exceptions.rb, line 113
    def inspect
      "#{message}: #{http_body}"
    end

message() click to toggle source

    # File lib/restclient/exceptions.rb, line 121
    def message
      @message || self.class.name
    end

to_s() click to toggle source

    # File lib/restclient/exceptions.rb, line 117
    def to_s
      inspect
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.