From 8e77831e2800b0d51ed7458cb246f09ce78c5a8c Mon Sep 17 00:00:00 2001 From: SebClem Date: Thu, 29 Aug 2024 15:21:35 +0200 Subject: [PATCH] Add more logs --- nextcloud_backup/backend/src/routes/config.ts | 5 ++--- .../backend/src/services/homeAssistantService.ts | 2 ++ nextcloud_backup/backend/src/services/webdavService.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nextcloud_backup/backend/src/routes/config.ts b/nextcloud_backup/backend/src/routes/config.ts index c720a13..b74df2b 100644 --- a/nextcloud_backup/backend/src/routes/config.ts +++ b/nextcloud_backup/backend/src/routes/config.ts @@ -57,11 +57,10 @@ configRouter.put("/webdav", (req, res) => { res.status(204).send(); }) .catch((error: ValidationError) => { - res.status(400); if (error.details) { - res.json({ type: "validation", errors: error.details }); + res.status(400).json({ type: "validation", errors: error.details }); } else { - res.json({ type: "validation", errors: error }); + res.status(400).json({ type: "validation", errors: error }); } }); }); diff --git a/nextcloud_backup/backend/src/services/homeAssistantService.ts b/nextcloud_backup/backend/src/services/homeAssistantService.ts index b7eac5d..0567486 100644 --- a/nextcloud_backup/backend/src/services/homeAssistantService.ts +++ b/nextcloud_backup/backend/src/services/homeAssistantService.ts @@ -37,6 +37,7 @@ const create_snap_timeout = process.env.CREATE_BACKUP_TIMEOUT : 90 * 60 * 1000; function getVersion(): Promise>> { + logger.info("Getting Home Assistant info"); return got>("http://hassio/core/info", { headers: { authorization: `Bearer ${token}` }, responseType: "json", @@ -57,6 +58,7 @@ function getVersion(): Promise>> { } function getAddonList(): Promise>> { + logger.info("Getting Addon list"); const option: OptionsOfJSONResponseBody = { headers: { authorization: `Bearer ${token}` }, responseType: "json", diff --git a/nextcloud_backup/backend/src/services/webdavService.ts b/nextcloud_backup/backend/src/services/webdavService.ts index 8e7a193..23dee65 100644 --- a/nextcloud_backup/backend/src/services/webdavService.ts +++ b/nextcloud_backup/backend/src/services/webdavService.ts @@ -46,6 +46,7 @@ export function checkWebdavLogin( config: WebdavConfig, silent: boolean = false ) { + logger.info("Checking webdab login"); const endpoint = getEndpoint(config); return got(config.url + endpoint, { method: "OPTIONS", @@ -64,7 +65,10 @@ export function checkWebdavLogin( }, (reason: RequestError) => { if (!silent) { - messageManager.error("Fail to connect to Webdav", reason.message); + messageManager.error( + "Fail to connect to Webdav", + reason?.message ? reason.message : reason.code + ); } const status = statusTools.getStatus(); status.webdav = { @@ -74,7 +78,7 @@ export function checkWebdavLogin( }; statusTools.setStatus(status); logger.error(`Fail to connect to Webdav`); - logger.error(reason); + logger.error(reason?.message ? reason.message : reason.code); return Promise.reject(reason); } );