mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 15:54:00 +08:00
Catch RecordInvalid errors and remove uneeded error_format function [SCI-7831]
This commit is contained in:
parent
93851b8c90
commit
2fc5772af3
1 changed files with 4 additions and 7 deletions
|
@ -39,12 +39,14 @@ module ProtocolImporters
|
|||
|
||||
TinyMceAsset.update_images(step_text, '[]', @user)
|
||||
|
||||
# 'Manually' create assets here. "Accept nasted attributes" won't work for assets
|
||||
# 'Manually' create assets here. "Accept nested attributes" won't work for assets
|
||||
step.assets << AttachmentsBuilder.generate(step_params.deep_symbolize_keys, user: @user, team: @team)
|
||||
step
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => invalid
|
||||
@errors[:protocol] = invalid.record.errors
|
||||
rescue StandardError => e
|
||||
@errors[:protocol] = format_error(e)
|
||||
@errors[:protocol] = e.message
|
||||
end
|
||||
|
||||
self
|
||||
|
@ -56,11 +58,6 @@ module ProtocolImporters
|
|||
|
||||
private
|
||||
|
||||
def format_error(err)
|
||||
error_type, *error_message = err.message.split(': ')[1].split(' ')
|
||||
{ error_type.downcase.to_sym => [error_message.join(' ')] }
|
||||
end
|
||||
|
||||
def valid?
|
||||
unless [@protocol_params, @user, @team].all?
|
||||
@errors[:invalid_arguments] = {
|
||||
|
|
Loading…
Reference in a new issue