From 1d07cee93de74ca282af66cad2b9328a50ff16d4 Mon Sep 17 00:00:00 2001 From: Shllokkk <140623894+Shllokkk@users.noreply.github.com> Date: Wed, 11 Mar 2026 12:29:11 +0530 Subject: [PATCH] =?UTF-8?q?feat:=20show=20error=20state=20in=20dashboard?= =?UTF-8?q?=20chart=20widget=20instead=20of=20throwing=20=E2=80=A6=20(#378?= =?UTF-8?q?37)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/js/frappe/widgets/chart_widget.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/widgets/chart_widget.js b/frappe/public/js/frappe/widgets/chart_widget.js index eda2048a67..b2a7612b99 100644 --- a/frappe/public/js/frappe/widgets/chart_widget.js +++ b/frappe/public/js/frappe/widgets/chart_widget.js @@ -60,6 +60,11 @@ export default class ChartWidget extends Widget { ); this.empty.hide().appendTo(this.body); + this.error_state = $( + `
` + ); + this.error_state.hide().appendTo(this.body); + this.chart_wrapper = $(`
`); this.chart_wrapper.appendTo(this.body); @@ -552,7 +557,18 @@ export default class ChartWidget extends Widget { heatmap_year: args && args.heatmap_year ? args.heatmap_year : null, }; } - return frappe.xcall(method, args); + return frappe.xcall(method, args, undefined, { + silent: true, + error: (err) => { + const message = JSON.parse(JSON.parse(err._server_messages)[0])?.message; + this.chart_wrapper.hide(); + this.loading.hide(); + this.$summary && this.$summary.hide(); + this.empty.hide(); + this.error_state.text(message); + this.error_state.show(); + }, + }); } async get_source_doctype() { @@ -588,9 +604,11 @@ export default class ChartWidget extends Widget { this.loading.hide(); this.$summary && this.$summary.hide(); this.empty.show(); + this.error_state.hide(); } else { this.loading.hide(); this.empty.hide(); + this.error_state.hide(); this.chart_wrapper.show(); this.chart_doc.document_type = await this.get_source_doctype();