Skip to content

Commit 8ae4743

Browse files
committed
Added descriptive error
1 parent c85d688 commit 8ae4743

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ const AWS3 = require('./lib/S3StorageSystem');
55
class StorageFactory {
66
static getInstance(storageMode, Region) {
77
if (!storageMode) {
8-
throw new Error('Please add a storage Mode');
8+
throw new Error('Please add a storage Instance');
99
}
1010
if (storageMode === 'GCLOUD') {
1111
return new GCLOUD();
1212
}
13-
if (storageMode === 'AWS') {
13+
else if (storageMode === 'AWS') {
1414
return new AWS3(Region);
1515
}
16-
if (storageMode === 'NFS') {
16+
else if (storageMode === 'NFS') {
1717
return new NFS();
1818
}
19+
else {
20+
throw new Error(`Cant recognize instance of ${storageMode}, Please Specify Instance of AWS, GCLOUD, NFS`);
21+
}
1922
}
2023
}
2124

test/sdk.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ describe('Simple Storage Test', () => {
66

77
//First stage Unit Test
88
it('should run', () => {
9-
let StorageInstance = storageSystem.getInstance('AWS', 'Asia');
9+
let StorageInstance = storageSystem.getInstance('AWS', '');
1010
StorageInstance.download('smc-v1-dev', 'dev_key.key', '/Users/nitrocode/tmp/');
11-
console.log(StorageInstance);
11+
console.log(StorageInstance);
1212
});
1313

1414
});

0 commit comments

Comments
 (0)