fix(logs): add special case for axios error to prevent huge error messages (#2468)
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user