Skip to content

Commit a5b3be6

Browse files
authored
Clean up obj property name and improve error creation (#551)
1 parent 0728156 commit a5b3be6

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
export class WorkerNotInitializedError extends Error {
2-
constructor(message: string = 'Worker not initialized') {
3-
super(message);
2+
constructor(message: string = 'Worker not initialized', options?: ErrorOptions) {
3+
super(message, options);
44
this.name = 'WorkerNotInitializedError';
5+
Object.setPrototypeOf(this, WorkerNotInitializedError.prototype);
56
}
67
}
78

89
export class MountError extends Error {
910
public override readonly cause?: Error;
1011

11-
constructor(message: string, cause?: Error) {
12-
super(message);
12+
constructor(message: string, options?: ErrorOptions) {
13+
super(message, options);
1314
this.name = 'MountError';
14-
this.cause = cause;
15+
Object.setPrototypeOf(this, MountError.prototype);
1516
}
1617
}

src/utils/Delayer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
export class CancellationError extends Error {
2-
constructor(key: string) {
3-
super(`Request cancelled for key: ${key}`);
2+
constructor(key: string, options?: ErrorOptions) {
3+
super(`Request cancelled for key: ${key}`, options);
44
this.name = 'CancellationError';
5+
Object.setPrototypeOf(this, CancellationError.prototype);
56
}
67
}
78

tst/unit/datastore/FileStore.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('FileStore', () => {
272272
expect(readdirSync(encTestDir)).toEqual([]);
273273

274274
await store.put('key', 'someValue');
275-
expect(readdirSync(encTestDir)).toEqual([encodedFilePath(encTestDir, 'test', 'key').relPath]);
275+
expect(readdirSync(encTestDir)).toEqual([encodedFilePath(encTestDir, 'test', 'key').fileName]);
276276
});
277277
});
278278

@@ -587,6 +587,6 @@ function encodedFilePath(dir: string, store: string, key: string) {
587587
const filePath = join(dir, `${store}.${stableHashCode(key)}.enc`);
588588
return {
589589
filePath,
590-
relPath: basename(filePath),
590+
fileName: basename(filePath),
591591
};
592592
}

0 commit comments

Comments
 (0)