Comparing version 1.3.0 to 1.3.1
29
index.js
@@ -12,2 +12,20 @@ 'use strict' | ||
class ZlibError extends Error { | ||
constructor (err) { | ||
super('zlib: ' + err.message) | ||
this.code = err.code | ||
this.errno = err.errno | ||
/* istanbul ignore if */ | ||
if (!this.code) | ||
this.code = 'ZLIB_ERROR' | ||
this.message = 'zlib: ' + err.message | ||
Error.captureStackTrace(this, this.constructor) | ||
} | ||
get name () { | ||
return 'ZlibError' | ||
} | ||
} | ||
// the Zlib class they all inherit from | ||
@@ -41,3 +59,8 @@ // This thing manages the queue of requests, and returns | ||
// this will throw if any options are invalid for the class selected | ||
this[_handle] = new realZlib[mode](opts) | ||
try { | ||
this[_handle] = new realZlib[mode](opts) | ||
} catch (er) { | ||
// make sure that all errors get decorated properly | ||
throw new ZlibError(er) | ||
} | ||
@@ -52,3 +75,3 @@ this[_onError] = (err) => { | ||
this[_handle].on('error', er => this[_onError](er)) | ||
this[_handle].on('error', er => this[_onError](new ZlibError(er))) | ||
this.once('end', () => this.close) | ||
@@ -127,3 +150,3 @@ } | ||
Buffer.concat = OriginalBufferConcat | ||
this[_onError](err) | ||
this[_onError](new ZlibError(err)) | ||
} finally { | ||
@@ -130,0 +153,0 @@ if (this[_handle]) { |
{ | ||
"name": "minizlib", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A small fast zlib stream built on [minipass](http://npm.im/minipass) and Node.js's zlib binding.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
15923
387