Skip to content

Commit c896a17

Browse files
fix: Show toast if there is any error in Page Script
1 parent 43e677a commit c896a17

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

frontend/src/components/PageScript.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import useStore from "@/store";
4949
import { posthog } from "@/telemetry";
5050
import { BuilderPage } from "@/types/Builder/BuilderPage";
5151
import { Dialog } from "frappe-ui";
52-
import { ref } from "vue";
52+
import { defineComponent, ref } from "vue";
5353
import { toast } from "vue-sonner";
5454
import CodeEditor from "./CodeEditor.vue";
5555
import PageClientScriptManager from "./PageClientScriptManager.vue";
@@ -75,10 +75,15 @@ const savePageDataScript = (value: string) => {
7575
store.setPageData(props.page);
7676
toast.success("Data script saved");
7777
})
78-
.catch((e: { message: string; exc: string }) => {
79-
const error_message = e.exc.split("\n").slice(-2)[0];
78+
.catch((e: { message: string; exc: string; messages: [string] }) => {
79+
let errorMessage = e.exc?.split("\n").slice(-2)[0];
80+
if (!errorMessage) {
81+
errorMessage = e.messages[0];
82+
}
8083
toast.error("Failed to save script", {
81-
description: error_message,
84+
description: defineComponent({
85+
template: `<div>${errorMessage}</div>`,
86+
}),
8287
});
8388
});
8489
};

0 commit comments

Comments
 (0)