Commit 9c5fc252c08c46239564a18250cc3d09354a620b
Improve error handling when there is no object sink
Charles Lehner committed on 2/17/2016, 3:04:03 AMParent: b390ecc4bf4d610b201252d8a8a0cd1ad8cd2748
Files changed
index.js | changed |
lib/pack.js | changed |
index.js | ||
---|---|---|
@@ -212,9 +212,10 @@ | ||
212 | 212 | } |
213 | 213 | |
214 | 214 | module.exports = function (opts) { |
215 | 215 | var ended |
216 | - var objectSink = opts.objectSink || pull.error('Missing object sink') | |
216 | + var objectSink = opts.objectSink || | |
217 | + function () { throw new Error('Missing object sink') } | |
217 | 218 | var hasObject = opts.hasObject || function (hash, cb) { cb(false) } |
218 | 219 | var getObjects = opts.getObjects || function (id, cb) { |
219 | 220 | cb(null, 0, pull.empty()) |
220 | 221 | } |
lib/pack.js | ||
---|---|---|
@@ -204,9 +204,9 @@ | ||
204 | 204 | } |
205 | 205 | |
206 | 206 | function readObject(abort, cb) { |
207 | 207 | if (ended) cb(ended) |
208 | - else if (abort) read(abort) | |
208 | + else if (abort) read(abort, function (err) { cb(ended = err || abort) }) | |
209 | 209 | else if (numObjects < 0) readHeader(cb) |
210 | 210 | else if (numObjects > 0) getObject(cb) |
211 | 211 | else if (expectChecksum) readTrailer(cb) |
212 | 212 | } |
Built with git-ssb-web