fix(logs): add special case for axios error to prevent huge error messages (#2468)

This commit is contained in:
Meier Lukas
2025-03-02 10:54:35 +01:00
committed by GitHub
parent e1d69f91e7
commit 9eb76634d0

View File

@@ -1,3 +1,4 @@
import { AxiosError } from "axios";
import cron from "node-cron"; import cron from "node-cron";
import { Stopwatch } from "@homarr/common"; import { Stopwatch } from "@homarr/common";
@@ -48,8 +49,15 @@ const createCallback = <TAllowedNames extends string, TName extends TAllowedName
} }
await creatorOptions.onCallbackSuccess?.(name); await creatorOptions.onCallbackSuccess?.(name);
} catch (error) { } catch (error) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions // Log AxiosError in a less detailed way to prevent very long output
creatorOptions.logger.logError(`Failed to run job '${name}': ${error}`); if (error instanceof AxiosError) {
creatorOptions.logger.logError(
`Failed to run job '${name}': [AxiosError] ${error.message} ${error.response?.status} ${error.response?.config.url}\n${error.stack}`,
);
} else {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
creatorOptions.logger.logError(`Failed to run job '${name}': ${error}`);
}
await creatorOptions.onCallbackError?.(name, error); await creatorOptions.onCallbackError?.(name, error);
} }
}; };