Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed bug where errCode isnt present

  • Loading branch information...
commit 49646b33928b265306ac96191da77481da416988 1 parent 84fbd42
@contra contra authored
Showing with 8 additions and 10 deletions.
  1. +4 −5 lib/nodester.js
  2. +1 −1  package.json
  3. +3 −4 src/nodester.coffee
View
9 lib/nodester.js
@@ -127,7 +127,7 @@
return this.get("app/" + name, cb);
};
Nodester.prototype.app_logs = function(name, cb) {
- return this.get("applogs" + name, cb);
+ return this.get("applogs/" + name, cb);
};
Nodester.prototype.appnpm_handler = function(name, package, action, cb) {
return this.post("appnpm", {
@@ -164,22 +164,21 @@
})();
handleResponse = function(cb) {
return __bind(function(err, res, body) {
- var errCause, errCode, errMessage, error, success;
- if (!(res.statusCode < 400)) {
+ var errCause, errCode, error, success;
+ if ((res != null) && res.statusCode > 400) {
errCode = res.statusCode;
}
if (body != null) {
try {
success = JSON.parse(body);
} catch (e) {
- errMessage = body;
errCause = "JSON Parse error!";
}
}
if (errCode) {
errCause = "HTTP Error " + errCode + " returned.";
}
- if ((success != null ? success.message : void 0) && !/^success/.exec(success != null ? success.status : void 0)) {
+ if ((success != null) && (success.message != null) && (success.status != null) && !/^success/.exec(success.status)) {
errCause = success.message;
}
if (!body) {
View
2  package.json
@@ -1,7 +1,7 @@
{
"name":"nodester-api",
"description":"A library to interact with Nodester",
- "version":"0.1.16",
+ "version":"0.1.17",
"homepage":"http://nodester.com/",
"repository":"git://github.com/nodester/nodester-api.git",
"author":"Contra <contra@nodester.com>",
View
7 src/nodester.coffee
@@ -69,17 +69,16 @@ class Nodester
handleResponse = (cb) ->
return (err, res, body) =>
- errCode = res.statusCode unless res.statusCode < 400
+ errCode = res.statusCode if res? and res.statusCode > 400
if body?
try
success = JSON.parse body
catch e
- errMessage = body
errCause = "JSON Parse error!"
if errCode then errCause = "HTTP Error #{ errCode } returned."
- if success?.message and not /^success/.exec success?.status then errCause = success.message
- unless body then errCause ?= "No response received."
+ if success? and success.message? and success.status? and not /^success/.exec success.status then errCause = success.message
+ errCause ?= "No response received." unless body
if errCause
error = {}
Please sign in to comment.
Something went wrong with that request. Please try again.