X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FErrorUtils.ts;h=872348795e4838f6dc6571e3f0650c7a2da38820;hb=61e0f0426f3b5ffb6738bc1f6b61ff9ed789377b;hp=0e3dbc50058c669c1c5a30a17c8ecbe14e9138c9;hpb=9bf0ef23c51160abc6866ad8d07eea85e308edb8;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/ErrorUtils.ts b/src/utils/ErrorUtils.ts index 0e3dbc50..87234879 100644 --- a/src/utils/ErrorUtils.ts +++ b/src/utils/ErrorUtils.ts @@ -34,7 +34,7 @@ export const handleFileException = ( fileType: FileType, error: NodeJS.ErrnoException, logPrefix: string, - params: HandleErrorParams = defaultErrorParams + params: HandleErrorParams = defaultErrorParams, ): void => { setDefaultErrorParams(params); const prefix = isNotEmptyString(logPrefix) ? `${logPrefix} ` : ''; @@ -56,10 +56,11 @@ export const handleFileException = ( logMsg = `${fileType} file ${file} error:`; } if (params?.consoleOut === true) { + logMsg = `${logMsg} `; if (params?.throwError) { - console.error(`${chalk.green(prefix)}${chalk.red(`${logMsg} `)}`, error); + console.error(`${chalk.green(prefix)}${chalk.red(logMsg)}`, error); } else { - console.warn(`${chalk.green(prefix)}${chalk.yellow(`${logMsg} `)}`, error); + console.warn(`${chalk.green(prefix)}${chalk.yellow(logMsg)}`, error); } } else if (params?.consoleOut === false) { if (params?.throwError) { @@ -77,7 +78,7 @@ export const handleSendMessageError = ( chargingStation: ChargingStation, commandName: RequestCommand | IncomingRequestCommand, error: Error, - params: HandleErrorParams = { throwError: false, consoleOut: false } + params: HandleErrorParams = { throwError: false, consoleOut: false }, ): void => { setDefaultErrorParams(params, { throwError: false, consoleOut: false }); logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error); @@ -88,7 +89,7 @@ export const handleSendMessageError = ( export const setDefaultErrorParams = ( params: HandleErrorParams, - defaultParams: HandleErrorParams = defaultErrorParams + defaultParams: HandleErrorParams = defaultErrorParams, ): HandleErrorParams => { params = { ...defaultParams, ...params }; return params;