From 010ea4ec8c6a02810a00362a356ee6a102fa65bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Busso?= <90727999+agustinbusso@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:13:23 -0300 Subject: [PATCH 1/2] Handle errors --- resources/js/processes/scripts/components/AiTab.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/js/processes/scripts/components/AiTab.vue b/resources/js/processes/scripts/components/AiTab.vue index 77cfbda0c2..a1e2e0ef96 100644 --- a/resources/js/processes/scripts/components/AiTab.vue +++ b/resources/js/processes/scripts/components/AiTab.vue @@ -314,8 +314,15 @@ export default { this.$emit("request-started", this.progress, this.$t("Generating")); } }) - .catch(() => { - const errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + .catch((error) => { + let errorMsg; + if (error.response && error.response.data && error.response.data.message) { + errorMsg = error.response.data.message; + } else if (error.message) { + errorMsg = error.message; + } else { + errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + } window.ProcessMaker.alert(errorMsg, "danger"); }); }, From d054477280377911f0a3ef3e1f7d21fcc577aa01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Busso?= <90727999+agustinbusso@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:16:40 -0300 Subject: [PATCH 2/2] Handle error for all ai script actions --- .../js/processes/scripts/components/AiTab.vue | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/resources/js/processes/scripts/components/AiTab.vue b/resources/js/processes/scripts/components/AiTab.vue index a1e2e0ef96..71b43ebb8b 100644 --- a/resources/js/processes/scripts/components/AiTab.vue +++ b/resources/js/processes/scripts/components/AiTab.vue @@ -360,8 +360,15 @@ export default { this.$emit("request-started", this.progress, this.$t("Cleaning")); } }) - .catch(() => { - const errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + .catch((error) => { + let errorMsg; + if (error.response && error.response.data && error.response.data.message) { + errorMsg = error.response.data.message; + } else if (error.message) { + errorMsg = error.message; + } else { + errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + } window.ProcessMaker.alert(errorMsg, "danger"); }); }, @@ -403,8 +410,15 @@ export default { ); } }) - .catch(() => { - const errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + .catch((error) => { + let errorMsg; + if (error.response && error.response.data && error.response.data.message) { + errorMsg = error.response.data.message; + } else if (error.message) { + errorMsg = error.message; + } else { + errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + } window.ProcessMaker.alert(errorMsg, "danger"); }); }, @@ -445,8 +459,15 @@ export default { ); } }) - .catch(() => { - const errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + .catch((error) => { + let errorMsg; + if (error.response && error.response.data && error.response.data.message) { + errorMsg = error.response.data.message; + } else if (error.message) { + errorMsg = error.message; + } else { + errorMsg = this.$t("ProcessMaker AI is currently offline. Please try again later."); + } window.ProcessMaker.alert(errorMsg, "danger"); }); },