Skip to content

Commit

Permalink
typescript client: added HTTP status code check
Browse files Browse the repository at this point in the history
matryer committed Oct 29, 2020
1 parent 33253a6 commit 875c675
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions otohttp/templates/client.ts.plush
Original file line number Diff line number Diff line change
@@ -35,6 +35,9 @@ export class Client {
headers: headers,
body: JSON.stringify(<%= camelize_down(method.InputObject.TypeName) %>),
})
if (response.status !== 200) {
throw new Error(`<%= service.Name %>.<%= method.Name %>: ${response.status} ${response.statusText}`);
}
return response.json().then((json) => {
if (json.error) {
throw new Error(json.error);

0 comments on commit 875c675

Please sign in to comment.