From 7f5ad041cc26f8a0240c2efbf9be9e6bb6e4fc39 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 3 Dec 2015 10:51:09 +0000 Subject: [PATCH] Pass the http status out with the error so upper level can can see what went wrong. --- lib/http-api.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/http-api.js b/lib/http-api.js index 1a4727712..55b20d4d4 100644 --- a/lib/http-api.js +++ b/lib/http-api.js @@ -117,13 +117,17 @@ module.exports.MatrixHttpApi.prototype = { clearTimeout(xhr.timeout_timer); if (!xhr.responseText) { - cb(new Error('No response body.')); + var err = new Error('No response body.'); + err.http_status = xhr.status; + cb(err); return; } var resp = JSON.parse(xhr.responseText); if (resp.content_uri === undefined) { - cb(new Error('Bad response')); + var err = Error('Bad response'); + err.http_status = xhr.status; + cb(err); return; }