Skip to content

Commit a1e20f8

Browse files
authored
Better error message on null node. Fixes #1875 (#1876)
1 parent 3190598 commit a1e20f8

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/plugins/TwoPhaseCommit/TwoPhaseCore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ define([
420420

421421
TwoPhaseCore.isValidNode = function (node) {
422422
const EXPECTED_KEYS = ['parent', 'children', 'relid'];
423-
const isGMENode = typeof node === 'object' &&
423+
const isGMENode = node && typeof node === 'object' &&
424424
EXPECTED_KEYS.reduce((valid, key) => valid && node.hasOwnProperty(key), true);
425425
return isGMENode || node instanceof CreatedNode;
426426
};

test/unit/plugins/TwoPhaseCommit/TwoPhaseCore.spec.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ describe('TwoPhaseCore', function() {
213213

214214
it('should check node types on loadChildren', async function() {
215215
const invalidNode = {relid: 'h'};
216-
try {
217-
await plugin.core.loadChildren(invalidNode);
218-
throw new Error('Did not throw exception.');
219-
} catch (err) {
220-
}
216+
await assert.rejects(() => plugin.core.loadChildren(invalidNode));
217+
});
218+
219+
it('should have meaningful error on null node', async function() {
220+
assert.throws(
221+
() => plugin.core.getAttribute(null, 'name'),
222+
/Expected node but found/
223+
);
221224
});
222225
});
223226
});

0 commit comments

Comments
 (0)