Exception: Familia::RecordExistsError

Inherits:
NonUniqueKey show all
Defined in:
lib/familia/errors.rb

Overview

Raised when attempting to create an object that already exists in the database

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, existing_id: nil) ⇒ RecordExistsError

Returns a new instance of RecordExistsError.



126
127
128
129
130
# File 'lib/familia/errors.rb', line 126

def initialize(key, existing_id: nil)
  @existing_id = existing_id
  @key = key
  super(key)
end

Instance Attribute Details

#existing_idObject (readonly)

Returns the value of attribute existing_id.



124
125
126
# File 'lib/familia/errors.rb', line 124

def existing_id
  @existing_id
end

#keyObject (readonly)

Returns the value of attribute key.



124
125
126
# File 'lib/familia/errors.rb', line 124

def key
  @key
end

Instance Method Details

#messageObject



132
133
134
135
136
# File 'lib/familia/errors.rb', line 132

def message
  msg = "Key already exists: #{key}"
  msg << " (existing_id=#{existing_id})" unless existing_id.nil?
  msg
end