X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2Fstorage%2FStorageFactory.ts;h=1c109e1be628bfe4bf99d4499ae6227cd8a200d7;hb=03e9d27705d90abb583fddcd0cc94b585110c633;hp=741b16316320563a2eb9bd70612e46fa204fb68a;hpb=edd134392e237a3242dc2093341df70244c51472;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/storage/StorageFactory.ts b/src/performance/storage/StorageFactory.ts index 741b1631..1c109e1b 100644 --- a/src/performance/storage/StorageFactory.ts +++ b/src/performance/storage/StorageFactory.ts @@ -1,10 +1,11 @@ // Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { StorageType } from '../../types/Storage'; import { JsonFileStorage } from './JsonFileStorage'; import { MikroOrmStorage } from './MikroOrmStorage'; import { MongoDBStorage } from './MongoDBStorage'; import type { Storage } from './Storage'; +import { BaseError } from '../../exception'; +import { StorageType } from '../../types'; export class StorageFactory { private constructor() { @@ -12,7 +13,7 @@ export class StorageFactory { } public static getStorage(type: StorageType, connectionUri: string, logPrefix: string): Storage { - let storageInstance: Storage = null; + let storageInstance: Storage | null = null; switch (type) { case StorageType.JSON_FILE: storageInstance = new JsonFileStorage(connectionUri, logPrefix); @@ -26,7 +27,7 @@ export class StorageFactory { // storageInstance = new MikroOrmStorage(connectionUri, logPrefix, type); // break; default: - throw new Error(`${logPrefix} Unknown storage type: ${type}`); + throw new BaseError(`${logPrefix} Unknown storage type: ${type}`); } return storageInstance; }