refactor: applied changes for pull request
[e-mobility-charging-stations-simulator.git] / src / performance / storage / JsonFileStorage.ts
index 87c12537e78310bf76a6cb52a8ca8ef2b52128ec..2a712a6008f61722ef21dddaac5acd2e3ba14d53 100644 (file)
@@ -3,9 +3,10 @@
 import fs from 'node:fs';
 import path from 'node:path';
 
+import { Storage } from './Storage';
+import { BaseError } from '../../exception';
 import { FileType, type Statistics } from '../../types';
-import { AsyncLock, AsyncLockType, Constants, FileUtils, Utils } from '../../utils';
-import { Storage } from '../internal';
+import { AsyncLock, AsyncLockType, Constants, ErrorUtils, Utils } from '../../utils';
 
 export class JsonFileStorage extends Storage {
   private fd: number | null = null;
@@ -31,7 +32,7 @@ export class JsonFileStorage extends Storage {
         );
       })
       .catch((error) => {
-        FileUtils.handleFileException(
+        ErrorUtils.handleFileException(
           this.dbName,
           FileType.PerformanceRecords,
           error as NodeJS.ErrnoException,
@@ -52,7 +53,7 @@ export class JsonFileStorage extends Storage {
         this.fd = fs.openSync(this.dbName, 'a+');
       }
     } catch (error) {
-      FileUtils.handleFileException(
+      ErrorUtils.handleFileException(
         this.dbName,
         FileType.PerformanceRecords,
         error as NodeJS.ErrnoException,
@@ -68,7 +69,7 @@ export class JsonFileStorage extends Storage {
         this.fd = null;
       }
     } catch (error) {
-      FileUtils.handleFileException(
+      ErrorUtils.handleFileException(
         this.dbName,
         FileType.PerformanceRecords,
         error as NodeJS.ErrnoException,
@@ -79,7 +80,7 @@ export class JsonFileStorage extends Storage {
 
   private checkPerformanceRecordsFile(): void {
     if (!this?.fd) {
-      throw new Error(
+      throw new BaseError(
         `${this.logPrefix} Performance records '${this.dbName}' file descriptor not found`
       );
     }