mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 08:34:49 +08:00
Format error before sending it from back-end [SCI-7831]
This commit is contained in:
parent
a78f113498
commit
c39b660fe3
2 changed files with 7 additions and 2 deletions
|
@ -195,7 +195,7 @@ function handleFormSubmit(modal) {
|
|||
HelperModule.flashAlertMsg(data.message, 'success');
|
||||
},
|
||||
error: function(data) {
|
||||
showFormErrors(modal, data.responseJSON.errors);
|
||||
showFormErrors(modal, data.responseJSON.validation_errors);
|
||||
},
|
||||
complete: function() {
|
||||
animateSpinner(modal, false);
|
||||
|
|
|
@ -44,7 +44,7 @@ module ProtocolImporters
|
|||
step
|
||||
end
|
||||
rescue StandardError => e
|
||||
@errors[:protocol] = e.message
|
||||
@errors[:protocol] = format_error(e)
|
||||
end
|
||||
|
||||
self
|
||||
|
@ -56,6 +56,11 @@ module ProtocolImporters
|
|||
|
||||
private
|
||||
|
||||
def format_error(e)
|
||||
error_type, *error_message = e.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…
Add table
Reference in a new issue