Add more fields to error responses with hint, detail and context for SQL errors.
This commit is contained in:
parent
7dde0d81f1
commit
d50ddbb10f
7
NEWS.md
7
NEWS.md
@ -1,7 +1,12 @@
|
|||||||
1.18.1 - 2014-mm-dd
|
1.19.0 - 2014-mm-dd
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
New features:
|
||||||
|
|
||||||
|
* Add more fields to error responses with hint, detail and context for SQL errors.
|
||||||
|
|
||||||
Enhancements:
|
Enhancements:
|
||||||
|
|
||||||
* Don't loop twice over svg rows
|
* Don't loop twice over svg rows
|
||||||
* Improve statement timeout error messages
|
* Improve statement timeout error messages
|
||||||
* Improve topojson output by streaming json
|
* Improve topojson output by streaming json
|
||||||
|
@ -569,6 +569,8 @@ function handleException(err, res) {
|
|||||||
error: [pgErrorHandler.getMessage()]
|
error: [pgErrorHandler.getMessage()]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_.defaults(msg, pgErrorHandler.getFields());
|
||||||
|
|
||||||
if (global.settings.environment == 'development') {
|
if (global.settings.environment == 'development') {
|
||||||
msg.stack = err.stack;
|
msg.stack = err.stack;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,14 @@ ErrorHandler.prototype.getMessage = function() {
|
|||||||
return message;
|
return message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ErrorHandler.prototype.getFields = function(fields) {
|
||||||
|
fields = fields || ['detail', 'hint', 'context'];
|
||||||
|
return fields.reduce(function (previousValue, current) {
|
||||||
|
previousValue[current] = this.err[current];
|
||||||
|
return previousValue;
|
||||||
|
}.bind(this), {});
|
||||||
|
};
|
||||||
|
|
||||||
ErrorHandler.prototype.getStatus = function() {
|
ErrorHandler.prototype.getStatus = function() {
|
||||||
var statusError = this.err.http_status || 400;
|
var statusError = this.err.http_status || 400;
|
||||||
|
|
||||||
|
43
npm-shrinkwrap.json
generated
43
npm-shrinkwrap.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cartodb_sql_api",
|
"name": "cartodb_sql_api",
|
||||||
"version": "1.18.1",
|
"version": "1.19.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cartodb-psql": {
|
"cartodb-psql": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
@ -61,7 +61,8 @@
|
|||||||
},
|
},
|
||||||
"nan": {
|
"nan": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"from": "nan@~1.1.0"
|
"from": "nan@~1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/nan/-/nan-1.1.2.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,42 +73,51 @@
|
|||||||
"express": {
|
"express": {
|
||||||
"version": "2.5.11",
|
"version": "2.5.11",
|
||||||
"from": "express@~2.5.11",
|
"from": "express@~2.5.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/express/-/express-2.5.11.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"connect": {
|
"connect": {
|
||||||
"version": "1.9.2",
|
"version": "1.9.2",
|
||||||
"from": "connect@1.x",
|
"from": "connect@1.x",
|
||||||
|
"resolved": "https://registry.npmjs.org/connect/-/connect-1.9.2.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"formidable": {
|
"formidable": {
|
||||||
"version": "1.0.15",
|
"version": "1.0.15",
|
||||||
"from": "formidable@1.0.x"
|
"from": "formidable@1.0.x",
|
||||||
|
"resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.15.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mime": {
|
"mime": {
|
||||||
"version": "1.2.4",
|
"version": "1.2.4",
|
||||||
"from": "mime@1.2.4"
|
"from": "mime@1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime/-/mime-1.2.4.tgz"
|
||||||
},
|
},
|
||||||
"qs": {
|
"qs": {
|
||||||
"version": "0.4.2",
|
"version": "0.4.2",
|
||||||
"from": "qs@0.4.x"
|
"from": "qs@0.4.x",
|
||||||
|
"resolved": "https://registry.npmjs.org/qs/-/qs-0.4.2.tgz"
|
||||||
},
|
},
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"from": "mkdirp@0.3.0"
|
"from": "mkdirp@0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"log4js": {
|
"log4js": {
|
||||||
"version": "0.6.21",
|
"version": "0.6.21",
|
||||||
"from": "log4js@~0.6.18",
|
"from": "log4js@~0.6.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/log4js/-/log4js-0.6.21.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": {
|
"async": {
|
||||||
"version": "0.2.10",
|
"version": "0.2.10",
|
||||||
"from": "async@~0.2.0"
|
"from": "async@~0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz"
|
||||||
},
|
},
|
||||||
"readable-stream": {
|
"readable-stream": {
|
||||||
"version": "1.0.33-1",
|
"version": "1.0.33",
|
||||||
"from": "readable-stream@~1.0.2",
|
"from": "readable-stream@~1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
@ -123,7 +133,7 @@
|
|||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"from": "inherits@2"
|
"from": "inherits@~2.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -136,11 +146,13 @@
|
|||||||
},
|
},
|
||||||
"lru-cache": {
|
"lru-cache": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"from": "lru-cache@~2.5.0"
|
"from": "lru-cache@~2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz"
|
||||||
},
|
},
|
||||||
"node-statsd": {
|
"node-statsd": {
|
||||||
"version": "0.0.7",
|
"version": "0.0.7",
|
||||||
"from": "node-statsd@~0.0.7"
|
"from": "node-statsd@~0.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-statsd/-/node-statsd-0.0.7.tgz"
|
||||||
},
|
},
|
||||||
"oauth-client": {
|
"oauth-client": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
@ -149,7 +161,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-uuid": {
|
"node-uuid": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"from": "node-uuid@1.1.0"
|
"from": "node-uuid@1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.1.0.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -159,7 +172,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-uuid": {
|
"node-uuid": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"from": "node-uuid@1.4.x"
|
"from": "node-uuid@1.4.x",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz"
|
||||||
},
|
},
|
||||||
"lru-cache": {
|
"lru-cache": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
@ -199,7 +213,8 @@
|
|||||||
},
|
},
|
||||||
"underscore": {
|
"underscore": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"from": "underscore@~1.6.0"
|
"from": "underscore@~1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"cartodb"
|
"cartodb"
|
||||||
],
|
],
|
||||||
"version": "1.18.1",
|
"version": "1.19.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/CartoDB/CartoDB-SQL-API.git"
|
"url": "git://github.com/CartoDB/CartoDB-SQL-API.git"
|
||||||
|
@ -671,7 +671,10 @@ test('COPY TABLE with GET and auth', function(done){
|
|||||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||||
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
|
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
|
||||||
assert.deepEqual(res.headers['content-disposition'], 'inline');
|
assert.deepEqual(res.headers['content-disposition'], 'inline');
|
||||||
assert.deepEqual(JSON.parse(res.body), {"error":["must be superuser to COPY to or from a file"]});
|
assert.deepEqual(JSON.parse(res.body), {
|
||||||
|
error: ["must be superuser to COPY to or from a file"],
|
||||||
|
hint: "Anyone can COPY to stdout or from stdin. psql's \\copy command also works for anyone."
|
||||||
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user