make error message returned as part of value

This commit is contained in:
Jonathan Lipps
2013-03-27 13:44:31 -07:00
parent c169d9796f
commit 4e57f01f9b
2 changed files with 19 additions and 4 deletions

View File

@@ -76,6 +76,8 @@ var respondError = function(req, res, statusObj, value) {
if (typeof newValue === "object") {
newValue = _.extend({message: message}, value);
} else {
newValue = {message: message, origValue: value};
}
var response = {status: code, value: newValue};
response.sessionId = getSessionId(req, response);
@@ -633,8 +635,10 @@ exports.notYetImplemented = function(req, res) {
res.send(501, {
status: status.codes.UnknownError.code
, sessionId: getSessionId(req)
, value: "Not yet implemented. " +
"Please help us: http://appium.io/get-involved.html"
, value: {
message: "Not yet implemented. " +
"Please help us: http://appium.io/get-involved.html"
}
});
};
@@ -644,8 +648,10 @@ var notImplementedInThisContext = function(req, res) {
res.send(501, {
status: status.codes.UnknownError.code
, sessionId: getSessionId(req)
, value: "Not implemented in this context, try switching " +
"into or out of a web view"
, value: {
message: "Not implemented in this context, try switching " +
"into or out of a web view"
}
});
};

View File

@@ -5,6 +5,7 @@
var assert = require("assert")
, describeWd = require("../../helpers/driverblock.js").describeForApp('TestApp')
, should = require('should')
, _ = require("underscore");
describeWd('calc app', function(h) {
@@ -192,4 +193,12 @@ describeWd('calc app', function(h) {
});
});
});
it('should receive correct error', function(done) {
h.driver.execute("mobile: doesn't exist", function(err) {
should.exist(err);
err.cause.value.message.should.equal("Not yet implemented. Please help us: http://appium.io/get-involved.html");
done();
});
});
});