mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Catching call for logs errors
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
3b3e6722fe
commit
95b638651f
@ -1,6 +1,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||
import type { ResourceDescriptor } from "../../../../common/k8s-api/kube-api";
|
||||
import loggerInjectable from "../../../../common/logger.injectable";
|
||||
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
||||
import callForLogsInjectable from "./call-for-logs.injectable";
|
||||
|
||||
@ -10,11 +11,18 @@ const downloadAllLogsInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const callForLogs = di.inject(callForLogsInjectable);
|
||||
const openSaveFileDialog = di.inject(openSaveFileDialogInjectable)
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return async (params: ResourceDescriptor, query: PodLogsQuery) => {
|
||||
const logs = await callForLogs(params, query)
|
||||
|
||||
openSaveFileDialog(`${params.name}.log`, logs, "text/plain");
|
||||
const logs = await callForLogs(params, query).catch(error => {
|
||||
logger.error("Can't download logs: ", error);
|
||||
|
||||
return "";
|
||||
})
|
||||
|
||||
if (logs) {
|
||||
openSaveFileDialog(`${params.name}.log`, logs, "text/plain");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user