Add more logs

This commit is contained in:
SebClem 2024-08-29 15:21:35 +02:00
parent f0e2125173
commit 8e77831e28
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
3 changed files with 10 additions and 5 deletions

View File

@ -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 });
}
});
});

View File

@ -37,6 +37,7 @@ const create_snap_timeout = process.env.CREATE_BACKUP_TIMEOUT
: 90 * 60 * 1000;
function getVersion(): Promise<Response<SupervisorResponse<CoreInfoBody>>> {
logger.info("Getting Home Assistant info");
return got<SupervisorResponse<CoreInfoBody>>("http://hassio/core/info", {
headers: { authorization: `Bearer ${token}` },
responseType: "json",
@ -57,6 +58,7 @@ function getVersion(): Promise<Response<SupervisorResponse<CoreInfoBody>>> {
}
function getAddonList(): Promise<Response<SupervisorResponse<AddonData>>> {
logger.info("Getting Addon list");
const option: OptionsOfJSONResponseBody = {
headers: { authorization: `Bearer ${token}` },
responseType: "json",

View File

@ -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);
}
);