Exception: RESTFramework::Errors::BulkRecordErrorsError

Inherits:
BaseError
  • Object
show all
Defined in:
lib/rest_framework/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ BulkRecordErrorsError

Returns a new instance of BulkRecordErrorsError.



48
49
50
51
52
53
# File 'lib/rest_framework/errors.rb', line 48

def initialize(records)
  @errors = records.each_with_index.filter_map { |record, i|
    next unless record.errors.any?
    { index: i, errors: record.errors.messages }
  }
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



46
47
48
# File 'lib/rest_framework/errors.rb', line 46

def errors
  @errors
end

Instance Method Details

#messageObject



60
61
62
63
64
# File 'lib/rest_framework/errors.rb', line 60

def message
  "Bulk operation failed due to validation errors on #{@errors.length} #{
    'record'.pluralize(@errors.length)
  }."
end

#recordObject

Allow e.try(:record).try(:errors) to chain through the standard error handler.



56
57
58
# File 'lib/rest_framework/errors.rb', line 56

def record
  self
end