Skip to content

Commit

Permalink
fix: Rest client error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat authored and mirceanis committed Sep 7, 2020
1 parent 3856479 commit b871a39
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/daf-rest/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ export class AgentRestClient implements IAgentPlugin {
method: supportedMethods[method].type,
body: JSON.stringify(args),
})
const json = await res.json()

if (res.status >= 400) {
throw Error('Bad response from server: ' + res.status + ' ' + res.statusText)
throw Error(json.error)
}

return res.json()
return json
}
}
}
Expand Down

0 comments on commit b871a39

Please sign in to comment.