pass through statusCode on errors (#54)
diff --git a/lib/client.js b/lib/client.js
index 45bef0c..b6666e8 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -92,7 +92,7 @@
message = `${reason.options.method} ${reason.options.url} Returned HTTP ${reason.statusCode} (${http.STATUS_CODES[reason.statusCode]}) --> "${responseError}"`
}
- throw new OpenWhiskError(message, reason.error)
+ throw new OpenWhiskError(message, reason.error, reason.statusCode)
}
// Error messages might be returned from platform or using custom
diff --git a/lib/openwhisk_error.js b/lib/openwhisk_error.js
index 73b26bc..eb64e17 100644
--- a/lib/openwhisk_error.js
+++ b/lib/openwhisk_error.js
@@ -3,11 +3,12 @@
'use strict';
-module.exports = function OpenWhiskError(message, error) {
+module.exports = function OpenWhiskError(message, error, statusCode) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.error = error;
+ this.statusCode = statusCode;
};
require('util').inherits(module.exports, Error);