Skip to content

Commit eff4a79

Browse files
test(helpers): cover doTry null/non-error branches (#391)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 8898a79 commit eff4a79

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/unit/helpers.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ describe('doTry', () => {
112112
assert.strictEqual(warnMessages.length, 1);
113113
assert.deepStrictEqual(warnMessages[0], ['[SQLite Explorer]', 'string error']);
114114
});
115+
116+
it('should return undefined and log warning on null error', () => {
117+
const result = doTry(() => { throw null; });
118+
assert.strictEqual(result, undefined);
119+
assert.strictEqual(warnMessages.length, 1);
120+
assert.deepStrictEqual(warnMessages[0], ['[SQLite Explorer]', 'null']);
121+
});
122+
123+
it('should return undefined and log warning on non-error object', () => {
124+
const result = doTry(() => { throw { toString: () => 'custom object error' }; });
125+
assert.strictEqual(result, undefined);
126+
assert.strictEqual(warnMessages.length, 1);
127+
assert.deepStrictEqual(warnMessages[0], ['[SQLite Explorer]', 'custom object error']);
128+
});
115129
});
116130

117131
describe('uiKindToString', () => {

0 commit comments

Comments
 (0)