Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/couchbase/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class CouchbaseError < StandardError
# @return [Hash] attributes associated with the error
attr_reader :context

def initialize(msg = nil, context = nil)
@context = context unless context.nil?
super(msg)
end

def to_s
defined?(@context) ? "#{super}, context=#{JSON.generate(@context)}" : super
end
Expand All @@ -30,6 +35,11 @@ class InvalidArgument < ArgumentError
# @return [Hash] attributes associated with the error
attr_reader :context

def initialize(msg = nil, context = nil)
@context = context unless context.nil?
super(msg)
end

def to_s
defined?(@context) ? "#{super}, context=#{JSON.generate(@context)}" : super
end
Expand Down