Comparing version 1.1.0 to 1.1.1
@@ -33,5 +33,12 @@ | ||
Encoder.prototype._transform = function(obj, enc, done) { | ||
var buf = this._msgpack.encode(obj).slice(0) | ||
var buf = null | ||
, header = null | ||
try { | ||
buf = this._msgpack.encode(obj).slice(0) | ||
} catch(err) { | ||
this.emit('error', err) | ||
return done() | ||
} | ||
if (this._header) { | ||
@@ -68,3 +75,7 @@ header = new Buffer(4) | ||
function decodeWithoutHeader(buf, enc, done) { | ||
this.push(this._msgpack.decode(buf)) | ||
try { | ||
this.push(this._msgpack.decode(buf)) | ||
} catch(err) { | ||
this.emit('error', err) | ||
} | ||
done() | ||
@@ -89,5 +100,9 @@ } | ||
if (this._chunks.length >= this._length) { | ||
this.push(this._msgpack.decode(this._chunks.slice(0, this._length))) | ||
this._chunks.consume(this._length) | ||
this._length = -1 | ||
try { | ||
this.push(this._msgpack.decode(this._chunks.slice(0, this._length))) | ||
this._chunks.consume(this._length) | ||
this._length = -1 | ||
} catch(err) { | ||
this.emit('error', err) | ||
} | ||
} | ||
@@ -94,0 +109,0 @@ |
{ | ||
"name": "msgpack5", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A msgpack v5 implementation for node.js, with extension points", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -100,1 +100,87 @@ | ||
}) | ||
test('encoding error wrapped', function(t) { | ||
t.plan(1) | ||
var pack = msgpack() | ||
, encoder = pack.encoder() | ||
, data = new MyType() | ||
function MyType() { | ||
} | ||
function mytypeEncode() { | ||
throw new Error('muahha') | ||
} | ||
function mytypeDecode() { | ||
} | ||
pack.register(0x42, MyType, mytypeEncode, mytypeDecode) | ||
encoder.on('error', function(err) { | ||
t.equal(err.message, 'muahha') | ||
}) | ||
encoder.end(data) | ||
}) | ||
test('decoding error wrapped', function(t) { | ||
t.plan(1) | ||
var pack = msgpack() | ||
, encoder = pack.encoder() | ||
, decoder = pack.decoder() | ||
, data = new MyType() | ||
function MyType() { | ||
} | ||
function mytypeEncode() { | ||
return new Buffer(0) | ||
} | ||
function mytypeDecode() { | ||
throw new Error('muahha') | ||
} | ||
pack.register(0x42, MyType, mytypeEncode, mytypeDecode) | ||
decoder.on('error', function(err) { | ||
t.equal(err.message, 'muahha') | ||
}) | ||
encoder.end(data) | ||
encoder.pipe(decoder) | ||
}) | ||
test('decoding error wrapped', function(t) { | ||
t.plan(1) | ||
var pack = msgpack() | ||
, encoder = pack.encoder({ header: false }) | ||
, decoder = pack.decoder({ header: false }) | ||
, data = new MyType() | ||
function MyType() { | ||
} | ||
function mytypeEncode() { | ||
return new Buffer(0) | ||
} | ||
function mytypeDecode() { | ||
throw new Error('muahha') | ||
} | ||
pack.register(0x42, MyType, mytypeEncode, mytypeDecode) | ||
decoder.on('error', function(err) { | ||
t.equal(err.message, 'muahha') | ||
}) | ||
encoder.end(data) | ||
encoder.pipe(decoder) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113015
2011