Skip to content

Commit 1252e94

Browse files
🧪 Add tests for doTry error handling fallback
This commit introduces new test cases for the `doTry` helper function. It adds assertions to verify the format of warning logs and tests the error fallback behavior when a non-`Error` object is thrown. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
1 parent 8cc23d8 commit 1252e94

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/unit/helpers.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,13 @@ describe('doTry', () => {
103103
const result = doTry(() => { throw new Error('test error'); });
104104
assert.strictEqual(result, undefined);
105105
assert.strictEqual(warnMessages.length, 1);
106+
assert.deepStrictEqual(warnMessages[0], ['[SQLite Explorer]', 'test error']);
107+
});
108+
109+
it('should return undefined and log warning on string error', () => {
110+
const result = doTry(() => { throw 'string error'; });
111+
assert.strictEqual(result, undefined);
112+
assert.strictEqual(warnMessages.length, 1);
113+
assert.deepStrictEqual(warnMessages[0], ['[SQLite Explorer]', 'string error']);
106114
});
107115
});

0 commit comments

Comments
 (0)