From 6d8a3265f25b87e21b37d5e533bd0f7a037214b7 Mon Sep 17 00:00:00 2001 From: Nathan Richards Date: Fri, 19 Jul 2024 12:20:19 +0200 Subject: [PATCH] chore: change message property name in http error - also some clean up of tests --- src/errors/httpError.ts | 6 +++--- src/errors/httpError.unit.spec.ts | 7 ------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/errors/httpError.ts b/src/errors/httpError.ts index ed8af583..33a61199 100644 --- a/src/errors/httpError.ts +++ b/src/errors/httpError.ts @@ -21,7 +21,7 @@ const statusCodeToErrorClassificationMap = new Map([ { type: ErrorName.SlippageError, code: LiFiErrorCode.SlippageError, - additionalMessage: ErrorMessage.SlippageError, + message: ErrorMessage.SlippageError, }, ], [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }], @@ -58,8 +58,8 @@ export class HTTPError extends BaseError { const errorClassification = getErrorClassificationFromStatusCode( response.status ) - const additionalMessage = errorClassification?.additionalMessage - ? `\n${errorClassification.additionalMessage}` + const additionalMessage = errorClassification?.message + ? `\n${errorClassification.message}` : '' const message = createInitialMessage(response) + additionalMessage diff --git a/src/errors/httpError.unit.spec.ts b/src/errors/httpError.unit.spec.ts index 3a01f9da..d5176028 100644 --- a/src/errors/httpError.unit.spec.ts +++ b/src/errors/httpError.unit.spec.ts @@ -19,7 +19,6 @@ describe('HTTPError', () => { code: LiFiErrorCode.ValidationError, jsonFunc: () => Promise.resolve(responseBody), responseBody, - htmlMessage: undefined, builtMessage: `[ValidationError] Request failed with status code 400 Bad Request responseMessage: Oops`, }, @@ -35,7 +34,6 @@ describe('HTTPError', () => { code: LiFiErrorCode.NotFound, jsonFunc: () => Promise.resolve(responseBody), responseBody, - htmlMessage: undefined, builtMessage: `[NotFoundError] Request failed with status code 404 Not Found responseMessage: Oops`, }, @@ -52,8 +50,6 @@ describe('HTTPError', () => { code: LiFiErrorCode.SlippageError, jsonFunc: () => Promise.resolve(responseBody), responseBody, - htmlMessage: - 'The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.', builtMessage: `[SlippageError] Request failed with status code 409 Conflict\nThe slippage is larger than the defined threshold. Please request a new route to get a fresh quote. responseMessage: Oops`, }, @@ -70,7 +66,6 @@ describe('HTTPError', () => { code: LiFiErrorCode.InternalError, jsonFunc: () => Promise.resolve(responseBody), responseBody, - htmlMessage: undefined, builtMessage: `[ServerError] Request failed with status code 500 Internal Server Error responseMessage: Oops`, }, @@ -86,7 +81,6 @@ describe('HTTPError', () => { code: LiFiErrorCode.InternalError, jsonFunc: () => Promise.resolve(responseBody), responseBody, - htmlMessage: undefined, builtMessage: `[ServerError] Request failed with an unknown error responseMessage: Oops`, }, @@ -101,7 +95,6 @@ describe('HTTPError', () => { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError, jsonFunc: () => Promise.reject(new Error('fail')), - htmlMessage: undefined, responseBody: undefined, builtMessage: `[ValidationError] Request failed with status code 400 Bad Request`, },