From f2907a151542d32144f0a0d73111823b10e5021e Mon Sep 17 00:00:00 2001 From: Chukwuemeka Ajima Date: Mon, 3 Jul 2023 13:19:46 +0200 Subject: [PATCH] chore(feedback): implement feedback - use correct error class for error handling. - change network error to server error --- packages/sdk-middleware-http/src/http.js | 8 ++++++-- packages/sdk-middleware-http/test/http.spec.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/sdk-middleware-http/src/http.js b/packages/sdk-middleware-http/src/http.js index b0ac8c00b..e6b805615 100644 --- a/packages/sdk-middleware-http/src/http.js +++ b/packages/sdk-middleware-http/src/http.js @@ -10,7 +10,11 @@ import type { Next, } from 'types/sdk' -import getErrorByCode, { NetworkError, HttpError } from './errors' +import getErrorByCode, { + NetworkError, + HttpError, + InternalServerError, +} from './errors' import parseHeaders from './parse-headers' function createError({ statusCode, message, ...rest }: Object): HttpErrorType { @@ -310,7 +314,7 @@ export default function createHttpMiddleware({ return } - const error = new NetworkError(err.message, { + const error = new InternalServerError(err.message, { originalRequest: request, retryCount, }) diff --git a/packages/sdk-middleware-http/test/http.spec.js b/packages/sdk-middleware-http/test/http.spec.js index ebd03fde9..7cc9886ac 100644 --- a/packages/sdk-middleware-http/test/http.spec.js +++ b/packages/sdk-middleware-http/test/http.spec.js @@ -1023,8 +1023,8 @@ describe('Http', () => { 'content-type': 'application/json', } - expect(res.error.code).toEqual(0) - expect(res.error.name).toEqual('NetworkError') + expect(res.error.code).toEqual(500) + expect(res.error.name).toEqual('InternalServerError') resolve() }