From b3850cb4fafac2c9fef0a51911fbaa94fe4abead Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Mon, 27 Mar 2023 16:15:11 +0530 Subject: [PATCH] fix: Show meaning full error message while creating and email inbox [CW-1312] (#6711) * chore: Shows error message while creating and email inbox * chore: Review fixes --------- Co-authored-by: Shivam Mishra --- .../inbox/channels/emailChannels/ForwardToOption.vue | 9 ++++++--- app/javascript/dashboard/store/modules/inboxes.js | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/emailChannels/ForwardToOption.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/emailChannels/ForwardToOption.vue index b9661438c..4e0a9c80e 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/emailChannels/ForwardToOption.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/emailChannels/ForwardToOption.vue @@ -63,6 +63,7 @@ export default { return { channelName: '', email: '', + alertMessage: '', }; }, computed: { @@ -101,9 +102,11 @@ export default { }, }); } catch (error) { - this.showAlert( - this.$t('INBOX_MGMT.ADD.EMAIL_CHANNEL.API.ERROR_MESSAGE') - ); + const errorMessage = error?.message; + this.alertMessage = + errorMessage || + this.$t('INBOX_MGMT.ADD.EMAIL_CHANNEL.API.ERROR_MESSAGE'); + this.showAlert(this.alertMessage); } }, }, diff --git a/app/javascript/dashboard/store/modules/inboxes.js b/app/javascript/dashboard/store/modules/inboxes.js index dcc656cb2..02ddaf05e 100644 --- a/app/javascript/dashboard/store/modules/inboxes.js +++ b/app/javascript/dashboard/store/modules/inboxes.js @@ -157,8 +157,9 @@ export const actions = { sendAnalyticsEvent(channel.type); return response.data; } catch (error) { + const errorMessage = error?.response?.data?.message; commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false }); - throw new Error(error); + throw new Error(errorMessage); } }, createWebsiteChannel: async ({ commit }, params) => {