From 8468e34b9fb783bd0f238bef6d0e2c7ae4e3456c Mon Sep 17 00:00:00 2001 From: Himanshu664 Date: Fri, 18 Feb 2022 10:47:50 +0530 Subject: [PATCH] Added Custom sound error message --- client/views/admin/customSounds/AddCustomSound.js | 7 ++----- client/views/admin/customSounds/lib.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/client/views/admin/customSounds/AddCustomSound.js b/client/views/admin/customSounds/AddCustomSound.js index 4dcc7d495b1f0..a60fd0d59977f 100644 --- a/client/views/admin/customSounds/AddCustomSound.js +++ b/client/views/admin/customSounds/AddCustomSound.js @@ -57,10 +57,7 @@ function AddCustomSound({ goToNew, close, onChange, ...props }) { return soundId; } validation.forEach((error) => { - throw new Error({ - type: 'error', - message: t('error-the-field-is-required', { field: t(error) }), - }); + throw new Error(t('error-the-field-is-required', { field: t(error) })); }); }, [dispatchToastMessage, insertOrUpdateSound, t, uploadCustomSound], @@ -73,7 +70,7 @@ function AddCustomSound({ goToNew, close, onChange, ...props }) { goToNew(result)(); onChange(); } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); + dispatchToastMessage({ type: 'error', message: error.message }); } }, [dispatchToastMessage, goToNew, name, onChange, saveAction, sound, t]); diff --git a/client/views/admin/customSounds/lib.js b/client/views/admin/customSounds/lib.js index 44420855af545..527d9c8e86fff 100644 --- a/client/views/admin/customSounds/lib.js +++ b/client/views/admin/customSounds/lib.js @@ -23,7 +23,7 @@ export function validate(soundData, soundFile) { export function createSoundData(soundFile, name = '', previousData) { const soundData = { - extension: soundFile.name.split('.').pop(), + extension: soundFile?.name.split('.').pop(), }; if (previousData) {