From f53ce53a2a1851d0af6a07a393abf412b6391639 Mon Sep 17 00:00:00 2001 From: Catalin <20538711+devcatalin@users.noreply.github.com> Date: Fri, 21 Jan 2022 15:37:19 +0200 Subject: [PATCH] chore: add error logging --- src/redux/services/projectConfig.ts | 7 +++++++ src/redux/thunks/loadKubeConfig.ts | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/redux/services/projectConfig.ts b/src/redux/services/projectConfig.ts index 2d84316ece..89c4ce45c7 100644 --- a/src/redux/services/projectConfig.ts +++ b/src/redux/services/projectConfig.ts @@ -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'; @@ -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 { @@ -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; } }; diff --git a/src/redux/thunks/loadKubeConfig.ts b/src/redux/thunks/loadKubeConfig.ts index 71b1805aa6..e22b77af97 100644 --- a/src/redux/thunks/loadKubeConfig.ts +++ b/src/redux/thunks/loadKubeConfig.ts @@ -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', @@ -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})); } };