From 77aace1f3d3ee7da338e7a8c2280a3e8f100716f Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Tue, 12 Mar 2024 15:27:31 +0530 Subject: [PATCH 1/2] Improved: Displayed server side error message if there any, else displayed the generic message in toast while creating user (#108). --- src/views/CreateUser.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/views/CreateUser.vue b/src/views/CreateUser.vue index 0c9a81f..6d61fc6 100644 --- a/src/views/CreateUser.vue +++ b/src/views/CreateUser.vue @@ -218,9 +218,14 @@ export default defineComponent({ } else { throw resp.data; } - } catch (err) { + } catch (err:any) { + console.log("==========test error=", err); + let errorMessage = translate('Failed to create user.'); + if(err?.response?.data?.error?.message) { + errorMessage = err.response.data.error.message + } console.error('error', err) - showToast(translate('Failed to create user.')) + showToast(errorMessage); } }, }, From 2249302616bf06df015f5a9e271b6960e18dba57 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Tue, 12 Mar 2024 15:29:10 +0530 Subject: [PATCH 2/2] Improved: Removed console log (#108). --- src/views/CreateUser.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/views/CreateUser.vue b/src/views/CreateUser.vue index 6d61fc6..f41e9e2 100644 --- a/src/views/CreateUser.vue +++ b/src/views/CreateUser.vue @@ -219,9 +219,8 @@ export default defineComponent({ throw resp.data; } } catch (err:any) { - console.log("==========test error=", err); let errorMessage = translate('Failed to create user.'); - if(err?.response?.data?.error?.message) { + if (err?.response?.data?.error?.message) { errorMessage = err.response.data.error.message } console.error('error', err)