Fix a null or undefined condition
[e-mobility-charging-stations-simulator.git] / src / utils / FileUtils.ts
index 87a8733b08f7e9108eb39f81b4d809200fb016d6..2e99f52f800834435d240bb418443bf429b31711 100644 (file)
@@ -22,7 +22,7 @@ export default class FileUtils {
     listener: fs.WatchListener<string> = (event, filename) => {
       if (filename && event === 'change') {
         try {
-          logger.debug(`${logPrefix} ${fileType} file ${file} + ' have changed, reload'`);
+          logger.debug(`${logPrefix} ${fileType} file ${file} have changed, reload`);
           refreshedVariable && (refreshedVariable = JSON.parse(fs.readFileSync(file, 'utf8')) as T);
         } catch (error) {
           FileUtils.handleFileException(logPrefix, fileType, file, error as NodeJS.ErrnoException, {
@@ -31,7 +31,7 @@ export default class FileUtils {
         }
       }
     }
-  ): fs.FSWatcher {
+  ): fs.FSWatcher | undefined {
     if (file) {
       try {
         return fs.watch(file, listener);
@@ -52,7 +52,7 @@ export default class FileUtils {
     error: NodeJS.ErrnoException,
     params: HandleErrorParams<EmptyObject> = { throwError: true, consoleOut: false }
   ): void {
-    const prefix = !Utils.isEmptyString(logPrefix) ? logPrefix + ' ' : '';
+    const prefix = !Utils.isEmptyString(logPrefix) ? `${logPrefix} ` : '';
     let logMsg: string;
     switch (error.code) {
       case 'ENOENT':