Skip to content

Commit

Permalink
chore: change message property name in http error
Browse files Browse the repository at this point in the history
- also some clean up of tests
  • Loading branch information
DNR500 committed Jul 19, 2024
1 parent 3e87711 commit 6d8a326
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/errors/httpError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }],
Expand Down Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions src/errors/httpError.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
},
Expand All @@ -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`,
},
Expand All @@ -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`,
},
Expand All @@ -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`,
},
Expand All @@ -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`,
},
Expand All @@ -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`,
},
Expand Down

0 comments on commit 6d8a326

Please sign in to comment.