Improve gzip error message

This commit is contained in:
Simon Martín 2018-08-10 14:38:50 +02:00
parent 9eeeadbc07
commit c0ea5be5d3
2 changed files with 3 additions and 2 deletions

View File

@ -126,6 +126,7 @@ function handleCopyFrom (logger) {
})
.pipe(isGzip ? zlib.createGunzip() : new PassThrough())
.on('error', err => {
err.message = `Error while gunzipping: ${err.message}`
metrics.end(null, err);
pgstream.emit('error', err);
})

View File

@ -187,7 +187,7 @@ describe('copy-endpoints', function() {
});
});
it('should return an error when gzip headers are not correct', function(done) {
it.only('should return an error when gzip headers are not correct', function(done) {
assert.response(server, {
url: "/api/v1/sql/copyfrom?" + querystring.stringify({
q: "COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT CSV, DELIMITER ',', HEADER true)"
@ -203,7 +203,7 @@ describe('copy-endpoints', function() {
assert.deepEqual(
JSON.parse(res.body),
{
error:["incorrect header check"]
error:["Error while gunzipping: incorrect header check"]
}
);
done();