Skip to content

Commit b08285a

Browse files
committed
stringify error to display full error message
1 parent 4150469 commit b08285a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/firestore/src/util/async_observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class AsyncObserver<T> implements Observer<T> {
4545
if (this.observer.error) {
4646
this.scheduleEvent(this.observer.error, error);
4747
} else {
48-
logError('Uncaught Error in snapshot listener:', error);
48+
logError('Uncaught Error in snapshot listener:', error.toString());
4949
}
5050
}
5151

packages/firestore/test/integration/api/query.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,36 @@ apiDescribe('Queries', (persistence: boolean) => {
649649
});
650650
});
651651

652+
it('can catch error message for missing index with error handler', () => {
653+
const testDocs = {
654+
'1': { sort: 1, filter: true, key: '1' },
655+
'2': { sort: 2, filter: true, key: '2' }
656+
};
657+
return withTestCollection(persistence, testDocs, async coll => {
658+
const query_ = query(
659+
coll,
660+
where('sort', '<=', '2'),
661+
where('filter', '==', true)
662+
);
663+
const deferred = new Deferred<void>();
664+
665+
const unsubscribe = onSnapshot(
666+
query_,
667+
() => {},
668+
err => {
669+
expect(err.code).to.equal('failed-precondition');
670+
expect(err.message).to.exist;
671+
expect(err.message).to.match(
672+
/index.*https:\/\/console\.firebase\.google\.com/
673+
);
674+
deferred.resolve();
675+
}
676+
);
677+
await deferred.promise;
678+
unsubscribe();
679+
});
680+
});
681+
652682
it('can explicitly sort by document ID', () => {
653683
const testDocs = {
654684
a: { key: 'a' },

0 commit comments

Comments
 (0)