Exception: CloudFS::RestAdapter::Errors::ClientError

Inherits:
HttpError
  • Object
show all
Defined in:
lib/cloudfs/client/error.rb

Overview

Base class of Client side errors - ConnectionFailed, TimeoutError

Direct Known Subclasses

ConnectionFailed, TimeoutError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, request = {}) ⇒ ClientError

Returns a new instance of ClientError.

Parameters:

  • error (Exception, String)
  • request (Hash) (defaults to: {})

    request context



163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/cloudfs/client/error.rb', line 163

def initialize(error, request={})
  if error.respond_to?(:backtrace)
    super(error.message)
    @original = error
    @code = -1
    @request = request
    # nothing informative to provide here
    @response = {:content => 'HTTPClient Error',
                 :content_type => 'application/text', :code => -1}
  else
    super(error.to_s)
  end
end

Instance Attribute Details

#codeFixnum (readonly)

Returns http status.

Returns:

  • (Fixnum)

    http status



152
153
154
# File 'lib/cloudfs/client/error.rb', line 152

def code
  @code
end

#requestHash (readonly)

{ :uri => String, :method => String, :params => String }

Returns:

  • (Hash)


159
160
161
# File 'lib/cloudfs/client/error.rb', line 159

def request
  @request
end

#response{ :content => "HTTPClient Error", :content_type => "application/text", :code => -1 } (readonly)

Is not informative, see backtrace for more info

Returns:

  • ({ :content => "HTTPClient Error", :content_type => "application/text", :code => -1 })

    response



156
157
158
# File 'lib/cloudfs/client/error.rb', line 156

def response
  @response
end

Instance Method Details

#backtraceString

Returns backtrace of original exception.

Returns:

  • (String)

    backtrace of original exception



178
179
180
# File 'lib/cloudfs/client/error.rb', line 178

def backtrace
  @original.backtrace if @original && @original.respond_to?(:backtrace)
end