Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #563 from Financial-Times/err-response-text
Browse files Browse the repository at this point in the history
save response text/json on heroku errors
  • Loading branch information
apaleslimghost authored Mar 28, 2019
2 parents cb71981 + b14b084 commit 2c558df
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/heroku-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ function herokuApi ({ endpoint, authToken, options = {} }) {
let err = new Error(`BadResponse: ${url} - ${status} ${statusText}`);
err.name = 'BAD_RESPONSE';
err.status = status;
throw err;
return response.text().then(text => {
try {
err.responseJson = JSON.parse(text);
} catch(_) {
err.repsonseText = text;
}

throw err;
});
}

return response.json();
Expand Down

0 comments on commit 2c558df

Please sign in to comment.