Skip to content

Commit

Permalink
chore(feedback): implement feedback
Browse files Browse the repository at this point in the history
- use correct error class for error handling.
- change network error to server error
  • Loading branch information
ajimae committed Jul 3, 2023
1 parent 5075964 commit f2907a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/sdk-middleware-http/src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -310,7 +314,7 @@ export default function createHttpMiddleware({
return
}

const error = new NetworkError(err.message, {
const error = new InternalServerError(err.message, {
originalRequest: request,
retryCount,
})
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-middleware-http/test/http.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit f2907a1

Please sign in to comment.