X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2Fstorage%2FJsonFileStorage.ts;h=2a712a6008f61722ef21dddaac5acd2e3ba14d53;hb=66dd344779f5258bbf4c76b386d005c0c2160b11;hp=87c12537e78310bf76a6cb52a8ca8ef2b52128ec;hpb=f682b2dcb6a9246fcd0f6e741f18af8e5b7f3e33;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/storage/JsonFileStorage.ts b/src/performance/storage/JsonFileStorage.ts index 87c12537..2a712a60 100644 --- a/src/performance/storage/JsonFileStorage.ts +++ b/src/performance/storage/JsonFileStorage.ts @@ -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` ); }