diff --git a/__tests__/unit/query.test.ts b/__tests__/unit/query.test.ts index 014ef6d6..3d8b37b4 100644 --- a/__tests__/unit/query.test.ts +++ b/__tests__/unit/query.test.ts @@ -5,6 +5,7 @@ import { AuthorizationError, FetchClient, fql, + ProtocolError, QueryTimeoutError, ServiceError, ServiceInternalError, @@ -123,7 +124,7 @@ describe("query", () => { expect(actual.summary).toEqual("the summary"); }); - it("Throws ServiceError on an empty 200 response", async () => { + it("Throws ProtocolError on an empty 200 response", async () => { expect.assertions(2); fetchMock.mockResponse("", { status: 200, @@ -133,9 +134,9 @@ describe("query", () => { const result = await client.query(fql`'foo'.length`); console.log("result", result); } catch (e) { - if (e instanceof ServiceError) { + if (e instanceof ProtocolError) { expect(e.message).toEqual( - "There was an issue communicating with Fauna. Please try again.", + "There was an issue communicating with Fauna. Response is empty. Please try again.", ); expect(e.httpStatus).toEqual(500); } diff --git a/src/client.ts b/src/client.ts index c623ec1a..e7c0efba 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,7 +11,6 @@ import { NetworkError, ProtocolError, ServiceError, - ServiceInternalError, ThrottlingError, getServiceError, } from "./errors"; @@ -646,16 +645,11 @@ in an environmental variable named FAUNA_SECRET or pass it to the Client\ response.body.length === 0 && response.headers["content-length"] === "0" ) { - throw new ServiceInternalError( - { - error: { - code: "internal_error", - message: - "There was an issue communicating with Fauna. Please try again.", - }, - }, - 500, - ); + throw new ProtocolError({ + message: + "There was an issue communicating with Fauna. Response is empty. Please try again.", + httpStatus: 500, + }); } let parsedResponse;