Skip to content

Commit

Permalink
fix(query): clean stack trace for filter cast errors so they include …
Browse files Browse the repository at this point in the history
…the calling file

Fix #8691
  • Loading branch information
vkarpov15 committed Mar 29, 2020
1 parent 0c09395 commit 074c6f5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3598,4 +3598,19 @@ describe('Query', function() {
assert.ok(res);
});
});

describe('stack traces', function() {
it('includes calling file for filter cast errors (gh-8691)', function() {
const toCheck = ['find', 'findOne', 'deleteOne'];
const Model = db.model('Test', Schema({}));

return co(function*() {
for (const fn of toCheck) {
const err = yield Model[fn]({ _id: 'fail' }).then(() => null, err => err);
assert.ok(err);
assert.ok(err.stack.includes(__filename), err.stack);
}
});
});
});
});

0 comments on commit 074c6f5

Please sign in to comment.