Exception: ViewModel::DeserializationError::DatabaseConstraint
- Inherits:
-
ViewModel::DeserializationError
- Object
- StandardError
- AbstractError
- AbstractErrorWithBlame
- ViewModel::DeserializationError
- ViewModel::DeserializationError::DatabaseConstraint
- Defined in:
- lib/view_model/deserialization_error.rb
Instance Attribute Summary collapse
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
Attributes inherited from AbstractErrorWithBlame
Class Method Summary collapse
-
.from_exception(exception, nodes = []) ⇒ Object
Database constraint errors are pretty opaque and stringly typed.
Instance Method Summary collapse
-
#initialize(detail, nodes = []) ⇒ DatabaseConstraint
constructor
A new instance of DatabaseConstraint.
Methods inherited from ViewModel::DeserializationError
Methods inherited from AbstractErrorWithBlame
Methods inherited from AbstractError
#aggregation?, #causes, #code, #exception, #meta, #status, #title, #to_s, #view
Constructor Details
#initialize(detail, nodes = []) ⇒ DatabaseConstraint
Returns a new instance of DatabaseConstraint.
357 358 359 360 |
# File 'lib/view_model/deserialization_error.rb', line 357 def initialize(detail, nodes = []) @detail = detail super(nodes) end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
355 356 357 |
# File 'lib/view_model/deserialization_error.rb', line 355 def detail @detail end |
Class Method Details
.from_exception(exception, nodes = []) ⇒ Object
Database constraint errors are pretty opaque and stringly typed. We can do our best to parse out what metadata we can from the error, and fall back when we can’t.
365 366 367 368 369 370 371 372 |
# File 'lib/view_model/deserialization_error.rb', line 365 def self.from_exception(exception, nodes = []) case exception.cause when PG::UniqueViolation, PG::ExclusionViolation UniqueViolation.from_postgres_error(exception.cause, nodes) else self.new(exception., nodes) end end |