Skip to content

Commit

Permalink
Merge pull request #343 from spree/fix-error-parsing
Browse files Browse the repository at this point in the history
Fix error parsing
  • Loading branch information
rafalcymerys authored Oct 3, 2022
2 parents 7b6c9ad + 4ea194b commit da7ed72
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ export default class Http {
}

protected processError(error: Error): SpreeSDKError {
if (error instanceof FetchError) {
if (error.response) {
if ((error as FetchError)?.response) {
const fetchError = (error as FetchError)
if (fetchError.response) {
// Error from Spree outside HTTP 2xx codes
return this.processSpreeError(error)
}

if (error.request) {
if (fetchError.request) {
// No response received from Spree
return new NoResponseError()
}
Expand Down

0 comments on commit da7ed72

Please sign in to comment.