Exception: Couchbase::Error::HTTP

Inherits:
Base
  • Object
show all
Defined in:
ext/couchbase_ext/couchbase_ext.c,
lib/couchbase/view.rb,
ext/couchbase_ext/couchbase_ext.c

Overview

HTTP error with status code

Since:

  • 1.2.0

Instance Attribute Summary collapse

Attributes inherited from Base

#cas, #error, #inner_exception, #key, #operation, #status

Instance Method Summary collapse

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



34
35
36
# File 'lib/couchbase/view.rb', line 34

def reason
  @reason
end

#typeObject (readonly)

Returns the value of attribute type.



34
35
36
# File 'lib/couchbase/view.rb', line 34

def type
  @type
end

Instance Method Details

#parse_body!Object



36
37
38
39
40
41
42
43
44
# File 'lib/couchbase/view.rb', line 36

def parse_body!
  if @body
    hash = MultiJson.load(@body)
    @type = hash["error"]
    @reason = hash["reason"]
  end
rescue MultiJson::DecodeError
  @type = @reason = nil
end

#to_sObject



46
47
48
49
50
51
52
53
# File 'lib/couchbase/view.rb', line 46

def to_s
  str = super
  if @type || @reason
    str.sub(/ \(/, ": #{[@type, @reason].compact.join(": ")} (")
  else
    str
  end
end