Skip to content

Commit

Permalink
Merge pull request #1089 from kubeshop/devcatalin/refator/better-logs
Browse files Browse the repository at this point in the history
chore: add error logging
  • Loading branch information
devcatalin authored Jan 21, 2022
2 parents 189d7f2 + f53ce53 commit 73d21e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/redux/services/projectConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {readFileSync, writeFileSync} from 'fs';
import _ from 'lodash';
import log from 'loglevel';
import {sep} from 'path';

import {AppConfig, ProjectConfig} from '@models/appconfig';
Expand All @@ -25,6 +26,9 @@ export const writeProjectConfigFile = (state: AppConfig | SerializableObject) =>
writeFileSync(absolutePath, JSON.stringify(projectConfig, null, 4), 'utf-8');
}
} catch (error: any) {
if (error instanceof Error) {
log.warn(`[writeProjectConfigFile]: ${error.message}`);
}
writeFileSync(absolutePath, JSON.stringify(projectConfig, null, 4), 'utf-8');
}
} else {
Expand Down Expand Up @@ -105,6 +109,9 @@ export const readProjectConfig = (projectRootPath?: string | null): ProjectConfi

return projectConfig;
} catch (error) {
if (error instanceof Error) {
log.warn(`[readProjectConfig]: ${error.message}`);
}
return null;
}
};
Expand Down
7 changes: 6 additions & 1 deletion src/redux/thunks/loadKubeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const loadContexts = async (

dispatch(updateProjectKubeConfig(kubeConfig));
} catch (e: any) {
if (e instanceof Error) {
log.warn(`[loadContexts]: ${e.message}`);
}
dispatch(
setAlert({
title: 'Loading kubeconfig file failed',
Expand All @@ -49,7 +52,9 @@ export const loadContexts = async (
}
}
} catch (e) {
log.info(e);
if (e instanceof Error) {
log.warn(e.message);
}
dispatch(updateProjectKubeConfig({isPathValid: false}));
}
};

0 comments on commit 73d21e6

Please sign in to comment.