Skip to content

Commit 8cfde5f

Browse files
committed
firestore-compat: cast unknown exceptions to FirestoreError
1 parent ab255d8 commit 8cfde5f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/firestore-compat/test/array_transforms.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ apiDescribe('Array Transforms:', (persistence: boolean) => {
189189
let errCaught = false;
190190
try {
191191
await docRef.get({ source: 'cache' });
192-
} catch (err) {
192+
} catch (e) {
193+
const err = e as firestore.FirestoreError;
193194
expect(err.code).to.equal('unavailable');
194195
errCaught = true;
195196
}

packages/firestore-compat/test/transactions.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ apiDescribe('Database transactions', (persistence: boolean) => {
116116
const snapshot = await this.docRef.get();
117117
expect(snapshot.exists).to.equal(true);
118118
expect(snapshot.data()).to.deep.equal(expected);
119-
} catch (err) {
119+
} catch (e) {
120+
const err = e as firestore.FirestoreError;
120121
expect.fail(
121122
'Expected the sequence (' +
122123
this.listStages(this.stages) +
@@ -133,7 +134,8 @@ apiDescribe('Database transactions', (persistence: boolean) => {
133134
await this.runTransaction();
134135
const snapshot = await this.docRef.get();
135136
expect(snapshot.exists).to.equal(false);
136-
} catch (err) {
137+
} catch (e) {
138+
const err = e as firestore.FirestoreError;
137139
expect.fail(
138140
'Expected the sequence (' +
139141
this.listStages(this.stages) +
@@ -150,8 +152,9 @@ apiDescribe('Database transactions', (persistence: boolean) => {
150152
await this.prepareDoc();
151153
await this.runTransaction();
152154
succeeded = true;
153-
} catch (err) {
154-
expect((err as firestore.FirestoreError).code).to.equal(expected);
155+
} catch (e) {
156+
const err = e as firestore.FirestoreError;
157+
expect(err.code).to.equal(expected);
155158
}
156159
if (succeeded) {
157160
expect.fail(

0 commit comments

Comments
 (0)