Improve row size limit error message
This commit is contained in:
parent
c590759302
commit
9b31df6793
4
NEWS.md
4
NEWS.md
@ -1,6 +1,10 @@
|
|||||||
1.21.1 - 2015-mm-dd
|
1.21.1 - 2015-mm-dd
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
Enhancements:
|
||||||
|
|
||||||
|
* Improve row size limit error message
|
||||||
|
|
||||||
|
|
||||||
1.21.0 - 2015-03-02
|
1.21.0 - 2015-03-02
|
||||||
-------------------
|
-------------------
|
||||||
|
@ -458,6 +458,7 @@ function handleQuery(req, res) {
|
|||||||
sql = new PSQL.QueryWrapper(sql).orderBy(orderBy, sortOrder).window(limit, offset).query();
|
sql = new PSQL.QueryWrapper(sql).orderBy(orderBy, sortOrder).window(limit, offset).query();
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
|
username: cdbUsername,
|
||||||
dbopts: dbopts,
|
dbopts: dbopts,
|
||||||
sink: res,
|
sink: res,
|
||||||
gn: gn,
|
gn: gn,
|
||||||
|
@ -33,13 +33,6 @@ PostgresFormat.prototype.handleQueryRowWithSkipFields = function(row, result) {
|
|||||||
this.handleQueryRow(row, result);
|
this.handleQueryRow(row, result);
|
||||||
};
|
};
|
||||||
|
|
||||||
PostgresFormat.prototype.handleQueryError = function(err) {
|
|
||||||
this.error = err;
|
|
||||||
if (err.message && err.message.match(/row too large, was \d* bytes/i)) {
|
|
||||||
console.error(JSON.stringify({error: err.message}));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PostgresFormat.prototype.handleNotice = function(msg, result) {
|
PostgresFormat.prototype.handleNotice = function(msg, result) {
|
||||||
if ( ! result.notices ) result.notices = [];
|
if ( ! result.notices ) result.notices = [];
|
||||||
for (var i=0; i<msg.length; i++) {
|
for (var i=0; i<msg.length; i++) {
|
||||||
@ -132,7 +125,16 @@ PostgresFormat.prototype.sendResponse = function(opts, callback) {
|
|||||||
query.on('row', that.handleQueryRow.bind(that));
|
query.on('row', that.handleQueryRow.bind(that));
|
||||||
}
|
}
|
||||||
query.on('end', that.handleQueryEnd.bind(that));
|
query.on('end', that.handleQueryEnd.bind(that));
|
||||||
query.on('error', that.handleQueryError.bind(that));
|
query.on('error', function(err) {
|
||||||
|
that.error = err;
|
||||||
|
if (err.message && err.message.match(/row too large, was \d* bytes/i)) {
|
||||||
|
console.error(JSON.stringify({
|
||||||
|
username: opts.username,
|
||||||
|
type: 'row_size_limit_exceeded',
|
||||||
|
error: err.message
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
query.on('notice', function(msg) {
|
query.on('notice', function(msg) {
|
||||||
that.handleNotice(msg, query._result);
|
that.handleNotice(msg, query._result);
|
||||||
});
|
});
|
||||||
|
@ -1492,7 +1492,10 @@ test('GET with callback must return 200 status error even if it is an error', fu
|
|||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
assert.equal(hit, true);
|
assert.equal(hit, true);
|
||||||
assert.ok(JSON.parse(consoleError).error.match(/^row too large.*/i), "Expecting row size limit error");
|
var parsedError = JSON.parse(consoleError);
|
||||||
|
assert.ok(parsedError.error.match(/^row too large.*/i), "Expecting row size limit error");
|
||||||
|
assert.equal(parsedError.username, 'vizzuality');
|
||||||
|
assert.equal(parsedError.type, 'row_size_limit_exceeded');
|
||||||
|
|
||||||
global.settings.db_max_row_size = dbMaxRowSize;
|
global.settings.db_max_row_size = dbMaxRowSize;
|
||||||
console.error = consoleErrorFn;
|
console.error = consoleErrorFn;
|
||||||
|
Loading…
Reference in New Issue
Block a user