Exception: Familia::RecordExistsError
- Inherits:
-
NonUniqueKey
- Object
- RuntimeError
- Problem
- PersistenceError
- NonUniqueKey
- Familia::RecordExistsError
- Defined in:
- lib/familia/errors.rb
Overview
Raised when attempting to create an object that already exists in the database
Instance Attribute Summary collapse
-
#existing_id ⇒ Object
readonly
Returns the value of attribute existing_id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, existing_id: nil) ⇒ RecordExistsError
constructor
A new instance of RecordExistsError.
- #message ⇒ Object
Constructor Details
#initialize(key, existing_id: nil) ⇒ RecordExistsError
Returns a new instance of RecordExistsError.
162 163 164 165 166 |
# File 'lib/familia/errors.rb', line 162 def initialize(key, existing_id: nil) @existing_id = existing_id @key = key super(key) end |
Instance Attribute Details
#existing_id ⇒ Object (readonly)
Returns the value of attribute existing_id.
160 161 162 |
# File 'lib/familia/errors.rb', line 160 def existing_id @existing_id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
160 161 162 |
# File 'lib/familia/errors.rb', line 160 def key @key end |
Instance Method Details
#message ⇒ Object
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/familia/errors.rb', line 168 def msg = "Key already exists: #{key}" begin msg << " (existing_id=#{existing_id})" unless existing_id.nil? rescue StandardError # existing_id may not support nil?/to_s (e.g. a Redis::Future captured # inside a MULTI); a diagnostic message must never raise itself. end msg end |