Exception: Couchbase::Error::HTTP

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/view.rb

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
45
46
47
48
49
# File 'lib/couchbase/view.rb', line 36

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

#to_sObject



51
52
53
54
55
56
57
58
# File 'lib/couchbase/view.rb', line 51

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