From 839c39d963104672a41da9477c153a545d7697c3 Mon Sep 17 00:00:00 2001 From: null Date: Wed, 9 Oct 2024 15:49:06 +0000 Subject: [PATCH 1/3] fix: axios error e.response undefined --- command-handler/src/util/axios-error-handler.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/command-handler/src/util/axios-error-handler.js b/command-handler/src/util/axios-error-handler.js index cda3db3..75e3349 100644 --- a/command-handler/src/util/axios-error-handler.js +++ b/command-handler/src/util/axios-error-handler.js @@ -1,7 +1,8 @@ export default function axiosError(e) { const errorObj = { - data: e.response.data, - status: e.response.status, + data: e.respone ? e.response.data : null, + status: e.response ? e.response.status : null, + message: e.message, stackTrace: e.stack } From 947bdd79df24c44dd5678288451ecbae889cfb42 Mon Sep 17 00:00:00 2001 From: null Date: Wed, 9 Oct 2024 15:58:58 +0000 Subject: [PATCH 2/3] fix: data is undefined when returned --- command-handler/src/util/hetzner/hetzner-servers.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/command-handler/src/util/hetzner/hetzner-servers.js b/command-handler/src/util/hetzner/hetzner-servers.js index 464eed0..5c0da44 100644 --- a/command-handler/src/util/hetzner/hetzner-servers.js +++ b/command-handler/src/util/hetzner/hetzner-servers.js @@ -228,6 +228,15 @@ export default { const userEmail = formatUser(info.user.profile.email); + if (!data) { + app.client.chat.postEphemeral({ + channel: `${body.channel.id}`, + user: `${body.user.id}`, + text: `Failed to get server data from hetzner` + }); + return []; + } + //list the servers and build the buttons for (const server of data.data.servers) { if (server.labels.owner === userEmail) { From 559bbacd0a067d2db13bb5c3c21d20cb7ed3a257 Mon Sep 17 00:00:00 2001 From: null Date: Wed, 9 Oct 2024 21:11:11 +0000 Subject: [PATCH 3/3] fix: spelling --- command-handler/src/util/axios-error-handler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command-handler/src/util/axios-error-handler.js b/command-handler/src/util/axios-error-handler.js index 75e3349..d1b7a5a 100644 --- a/command-handler/src/util/axios-error-handler.js +++ b/command-handler/src/util/axios-error-handler.js @@ -1,7 +1,7 @@ export default function axiosError(e) { const errorObj = { - data: e.respone ? e.response.data : null, - status: e.response ? e.response.status : null, + data: e.response?.data ?? null, + status: e.response?.status ?? null, message: e.message, stackTrace: e.stack