mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-23 05:13:53 +01:00
Always fill err.message on throw
This commit is contained in:
parent
9728a846c1
commit
bd0879c1cd
3 changed files with 8 additions and 15 deletions
|
@ -358,7 +358,7 @@ function deflate(input, options) {
|
||||||
deflator.push(input, true);
|
deflator.push(input, true);
|
||||||
|
|
||||||
// That will never happens, if you don't cheat with options :)
|
// That will never happens, if you don't cheat with options :)
|
||||||
if (deflator.err) { throw deflator.msg; }
|
if (deflator.err) { throw deflator.msg || msg[deflator.err]; }
|
||||||
|
|
||||||
return deflator.result;
|
return deflator.result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ function inflate(input, options) {
|
||||||
inflator.push(input, true);
|
inflator.push(input, true);
|
||||||
|
|
||||||
// That will never happens, if you don't cheat with options :)
|
// That will never happens, if you don't cheat with options :)
|
||||||
if (inflator.err) { throw inflator.msg; }
|
if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
|
||||||
|
|
||||||
return inflator.result;
|
return inflator.result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
|
|
||||||
var zlib = require('zlib');
|
var zlib = require('zlib');
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
var pako = require('../index');
|
var pako = require('../index');
|
||||||
var helpers = require('./helpers');
|
var helpers = require('./helpers');
|
||||||
|
@ -170,17 +171,9 @@ describe('Inflate with dictionary', function () {
|
||||||
// var zCompressed = helpers.deflateSync('world', { dictionary: new Buffer('hello') });
|
// var zCompressed = helpers.deflateSync('world', { dictionary: new Buffer('hello') });
|
||||||
var zCompressed = new Buffer([ 120, 187, 6, 44, 2, 21, 43, 207, 47, 202, 73, 1, 0, 6, 166, 2, 41 ]);
|
var zCompressed = new Buffer([ 120, 187, 6, 44, 2, 21, 43, 207, 47, 202, 73, 1, 0, 6, 166, 2, 41 ]);
|
||||||
|
|
||||||
try {
|
assert.throws(function () {
|
||||||
pako.inflate(zCompressed, { dictionary: new Buffer('world') });
|
pako.inflate(zCompressed, { dictionary: new Buffer('world') });
|
||||||
} catch (err) {
|
}, /data error/);
|
||||||
if (err.message === 'stream error') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error('Did not throw');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('trivial dictionary', function (done) {
|
it('trivial dictionary', function (done) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue