Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/functions/src/callable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
import { makeFakeApp, createTestService } from '../test/utils';
import { httpsCallable } from './service';
import { FUNCTIONS_TYPE } from './constants';
import { FunctionsError } from './error';

// eslint-disable-next-line @typescript-eslint/no-require-imports
export const TEST_PROJECT = require('../../../config/project.json');
Expand All @@ -52,9 +53,10 @@ async function expectError(
await promise;
} catch (e) {
failed = true;
expect(e.code).to.equal(`${FUNCTIONS_TYPE}/${code}`);
expect(e.message).to.equal(message);
expect(e.details).to.deep.equal(details);
const error = e as FunctionsError;
expect(error.code).to.equal(`${FUNCTIONS_TYPE}/${code}`);
expect(error.message).to.equal(message);
expect(error.details).to.deep.equal(details);
}
if (!failed) {
expect(false, 'Promise should have failed.').to.be.true;
Expand Down
2 changes: 1 addition & 1 deletion packages/remote-config/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export async function fetchConfig(remoteConfig: RemoteConfig): Promise<void> {

await rc._storageCache.setLastFetchStatus('success');
} catch (e) {
const lastFetchStatus = hasErrorCode(e, ErrorCode.FETCH_THROTTLE)
const lastFetchStatus = hasErrorCode(e as Error, ErrorCode.FETCH_THROTTLE)
? 'throttle'
: 'failure';
await rc._storageCache.setLastFetchStatus(lastFetchStatus);
Expand Down
4 changes: 2 additions & 2 deletions packages/storage/src/platform/node/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class FetchConnection<T extends ConnectionType>
this.errorCode_ = ErrorCode.NO_ERROR;
this.body_ = await response.arrayBuffer();
} catch (e) {
this.errorText_ = e.message;
this.errorText_ = (e as Error)?.message;
// emulate XHR which sets status to 0 when encountering a network error
this.statusCode_ = 0;
this.errorCode_ = ErrorCode.NETWORK_ERROR;
Expand Down Expand Up @@ -171,7 +171,7 @@ export class FetchStreamConnection extends FetchConnection<NodeJS.ReadableStream
this.errorCode_ = ErrorCode.NO_ERROR;
this.stream_ = response.body;
} catch (e) {
this.errorText_ = e.message;
this.errorText_ = (e as Error)?.message;
// emulate XHR which sets status to 0 when encountering a network error
this.statusCode_ = 0;
this.errorCode_ = ErrorCode.NETWORK_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class UploadTask {
this._makeProgressCallback()
);
} catch (e) {
this._error = e;
this._error = e as StorageError;
this._transition(InternalTaskState.ERROR);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/test/browser/blob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('Firebase Storage > Blob', () => {
await getBlob(reference);
expect.fail();
} catch (e) {
expect(e.message).to.satisfy((v: string) =>
expect((e as Error)?.message).to.satisfy((v: string) =>
v.match(/Object 'public\/exp-bytes-missing' does not exist/)
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/storage/test/integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('FirebaseStorage Exp', () => {
await getBytes(reference);
expect.fail();
} catch (e) {
expect(e.message).to.satisfy((v: string) =>
expect((e as Error)?.message).to.satisfy((v: string) =>
v.match(/Object 'public\/exp-bytes-missing' does not exist/)
);
}
Expand All @@ -130,7 +130,7 @@ describe('FirebaseStorage Exp', () => {
await uploadString(reference, 'foo');
expect.fail();
} catch (e) {
expect(e.message).to.satisfy((v: string) =>
expect((e as Error)?.message).to.satisfy((v: string) =>
v.match(
/The operation 'uploadString' cannot be performed on a root reference/
)
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/test/node/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Firebase Storage > getStream', () => {
await readData(stream);
expect.fail();
} catch (e) {
expect(e.message).to.satisfy((v: string) =>
expect((e as Error)?.message).to.satisfy((v: string) =>
v.match(/Object 'public\/exp-bytes-missing' does not exist/)
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/test/unit/testshared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function assertThrows(f: () => void, code: string): StorageError {
try {
f();
} catch (e) {
captured = e;
captured = e as StorageError;
throw e;
}
}).to.throw();
Expand Down