From 649b1ea3f1fd15f33a8e2592053af827fbcc8d3e Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Wed, 27 Mar 2024 02:14:14 +0530 Subject: [PATCH] err handling --- src/js/control-view.js | 32 ++++++++++++++++++------------ src/pug/templates/control-view.pug | 4 ++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/js/control-view.js b/src/js/control-view.js index 19f64a0..e72fda5 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -304,23 +304,27 @@ module.exports = { this.showGcodeMessage = true; while (this.showGcodeMessage) { - const toolpath = await api.get(`path/${file}`); - this.toolpath_progress = toolpath.progress; + try { + const toolpath = await api.get(`path/${file}`); + this.toolpath_progress = toolpath.progress; - if (toolpath.progress === 1 || typeof toolpath.progress == "undefined") { - this.showGcodeMessage = false; + if (toolpath.progress === 1 || typeof toolpath.progress == "undefined") { + this.showGcodeMessage = false; - if (toolpath.bounds) { - toolpath.filename = file; - this.toolpath_progress = 1; - this.toolpath = toolpath; + if (toolpath.bounds) { + toolpath.filename = file; + this.toolpath_progress = 1; + this.toolpath = toolpath; - const state = this.$root.state; - for (const axis of "xyzabc") { - Vue.set(state, `path_min_${axis}`, toolpath.bounds.min[axis]); - Vue.set(state, `path_max_${axis}`, toolpath.bounds.max[axis]); + const state = this.$root.state; + for (const axis of "xyzabc") { + Vue.set(state, `path_min_${axis}`, toolpath.bounds.min[axis]); + Vue.set(state, `path_max_${axis}`, toolpath.bounds.max[axis]); + } } } + } catch (error) { + console.error(error); } } }, @@ -445,7 +449,9 @@ module.exports = { delete_current: function () { if (this.config.macros_list.find(item => item.file_name == this.state.selected) == undefined) { if (this.state.selected) { - this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected); + this.config.non_macros_list = this.config.non_macros_list.filter( + item => item.file_name != this.state.selected, + ); api.delete(`file/${this.state.selected}`); } } else { diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index 6c774c4..6657161 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -22,9 +22,9 @@ script#control-view-template(type="text/x-template") h3(slot="header") Run Macro? div(slot="body") p - | The macro file + | The macro file strong {{state.selected}} - | is being loaded. + | is being loaded. div(slot="footer") button.pure-button(@click="macrosLoading=false") Cancel