wadl-client
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "wadl-client", | ||
"main": "wadl-client.js", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"homepage": "https://github.com/rbelouin/wadl-client", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "wadl-client", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Generate a Javascript client for a web API providing a WADL description", | ||
@@ -5,0 +5,0 @@ "main": "wadl-client.js", |
@@ -218,2 +218,11 @@ var swagger = { | ||
} | ||
}, | ||
"/test/catch": { | ||
"get": { | ||
"responses": { | ||
"default": { | ||
"description": "catch" | ||
} | ||
} | ||
} | ||
} | ||
@@ -220,0 +229,0 @@ } |
@@ -127,2 +127,6 @@ var http = require("http"); | ||
app.get("/test/catch", function(req, res) { | ||
res.send(); | ||
}); | ||
var server; | ||
@@ -129,0 +133,0 @@ |
@@ -260,2 +260,25 @@ var swagger = swagger || require("./swagger.js"); | ||
}); | ||
it("must not catch an error that is thrown in an onValue callback", function(done) { | ||
if(typeof window != "undefined") { | ||
console.log("This test is not compliant with browser environments"); | ||
done(); | ||
} | ||
else { | ||
var req = client.test.catch.get().send(); | ||
var d = require("domain").create(); | ||
d.on("error", function(error) { | ||
expect(error.message).toBe("UNCAUGHT ERROR"); | ||
done(); | ||
}); | ||
d.run(function() { | ||
req.onValue(function() { | ||
throw new Error("UNCAUGHT ERROR"); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); |
@@ -97,17 +97,20 @@ var WadlClient = (function() { | ||
var req = request(options, function(error, response, body) { | ||
var parseResult; | ||
try { | ||
if(error) { | ||
Utils.logError(options.logger, error); | ||
Utils.send(sink, new B.Error(error)); | ||
parseResult = new B.Error(error); | ||
} | ||
else if(response.statusCode >= 200 && response.statusCode < 300) { | ||
Utils.send(sink, options.parse ? Utils.parseBody(response, body) : body); | ||
parseResult = options.parse ? Utils.parseBody(response, body) : body; | ||
} | ||
else { | ||
Utils.send(sink, new B.Error(options.parse ? Utils.parseBody(response, body) : body)); | ||
parseResult = new B.Error(options.parse ? Utils.parseBody(response, body) : body); | ||
} | ||
} catch(e) { | ||
Utils.logError(options.logger, "An error occured while parsing: " + body); | ||
Utils.send(sink, new B.Error(e)); | ||
parseResult = new B.Error(e); | ||
} | ||
Utils.send(sink, parseResult); | ||
}); | ||
@@ -114,0 +117,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29675
925