diff --git a/.changeset/tough-taxis-travel.md b/.changeset/tough-taxis-travel.md new file mode 100644 index 00000000000..eab1d8dee7f --- /dev/null +++ b/.changeset/tough-taxis-travel.md @@ -0,0 +1,5 @@ +--- +'@firebase/auth': patch +--- + +Modify \_fail to use AuthErrorCode.INTERNAL_ERROR and pass in error message. diff --git a/packages/auth/src/api/index.test.ts b/packages/auth/src/api/index.test.ts index 74da561f273..579f6c5e8ad 100644 --- a/packages/auth/src/api/index.test.ts +++ b/packages/auth/src/api/index.test.ts @@ -308,6 +308,26 @@ describe('api/_performApiRequest', () => { }); }); + context('with non-Firebase Errors', () => { + afterEach(mockFetch.tearDown); + + it('should handle non-FirebaseErrors', async () => { + mockFetch.setUpWithOverride(() => { + return new Promise((_, reject) => reject(new Error('error'))); + }); + const promise = _performApiRequest( + auth, + HttpMethod.POST, + Endpoint.SIGN_UP, + request + ); + await expect(promise).to.be.rejectedWith( + FirebaseError, + 'auth/internal-error' + ); + }); + }); + context('with network issues', () => { afterEach(mockFetch.tearDown); @@ -345,24 +365,6 @@ describe('api/_performApiRequest', () => { expect(clock.clearTimeout).to.have.been.called; clock.restore(); }); - - it('should handle network failure', async () => { - mockFetch.setUpWithOverride(() => { - return new Promise((_, reject) => - reject(new Error('network error')) - ); - }); - const promise = _performApiRequest( - auth, - HttpMethod.POST, - Endpoint.SIGN_UP, - request - ); - await expect(promise).to.be.rejectedWith( - FirebaseError, - 'auth/network-request-failed' - ); - }); }); context('edgcase error mapping', () => { diff --git a/packages/auth/src/api/index.ts b/packages/auth/src/api/index.ts index 47c292868f4..0194c43d9a5 100644 --- a/packages/auth/src/api/index.ts +++ b/packages/auth/src/api/index.ts @@ -181,7 +181,7 @@ export async function _performFetchWithErrorHandling( if (e instanceof FirebaseError) { throw e; } - _fail(auth, AuthErrorCode.NETWORK_REQUEST_FAILED); + _fail(auth, AuthErrorCode.INTERNAL_ERROR, { 'message': String(e) }); } }