Skip to content

Commit

Permalink
Fix #7 - check response.ok.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 29, 2018
1 parent e8a6f07 commit 3edfc48
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/blob.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function responseBlob(response) {
if (!response.ok) throw new Error(response.status + " " + response.statusText);
return response.blob();
}

Expand Down
1 change: 1 addition & 0 deletions src/buffer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function responseArrayBuffer(response) {
if (!response.ok) throw new Error(response.status + " " + response.statusText);
return response.arrayBuffer();
}

Expand Down
1 change: 1 addition & 0 deletions src/json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function responseJson(response) {
if (!response.ok) throw new Error(response.status + " " + response.statusText);
return response.json();
}

Expand Down
1 change: 1 addition & 0 deletions src/text.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function responseText(response) {
if (!response.ok) throw new Error(response.status + " " + response.statusText);
return response.text();
}

Expand Down

0 comments on commit 3edfc48

Please sign in to comment.