From d8fb80059583704ede9fc80481b3b54e79eae918 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Wed, 1 Nov 2023 15:33:16 +0800 Subject: [PATCH] Improve error handling --- src/components/ShellView/ShellCell.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/ShellView/ShellCell.vue b/src/components/ShellView/ShellCell.vue index 841d987..b52e908 100644 --- a/src/components/ShellView/ShellCell.vue +++ b/src/components/ShellView/ShellCell.vue @@ -101,8 +101,14 @@ export default { this.errorMessage = String(error).trim(); } else { - this.errorMessage = error.response.data.error.trim(); - console.error(error.response.data.error.trim()); + try { + this.errorMessage = error.response.data.error.trim(); + console.error(error.response.data.error.trim()); + } catch (e) { + const httpStatus = error.response.status; + this.errorMessage = `The request failed with HTTP status code ${httpStatus}: ${error.response.statusText}`; + console.error(`The request failed with HTTP status code ${httpStatus}: ${error.response.statusText}`); + } } if (this.errorMessage) { this.$nextTick(() => {