lib/couchbase-orm/error.rb in couchbase-orm-1.1.1 vs lib/couchbase-orm/error.rb in couchbase-orm-2.0.0

- old
+ new

@@ -1,15 +1,30 @@ # frozen_string_literal: true, encoding: ASCII-8BIT module CouchbaseOrm class Error < ::StandardError attr_reader :record - + def initialize(message = nil, record = nil) @record = record super(message) end - class RecordInvalid < Error; end + class RecordInvalid < Error + def initialize(message = nil, record = nil) + if record + errors = record.errors.full_messages.join(", ") + message = I18n.t( + :"couchbase.#{record.class.design_document}.errors.messages.record_invalid", + errors: errors, + default: :"couchbase.errors.messages.record_invalid" + ) + end + super(message, record) + end + end + class TypeMismatchError < Error; end class RecordExists < Error; end + class CouchbaseOrm::Error::EmptyNotAllowed < Error; end end + class StrictLoadingViolationError < Error; end end