Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bubble errors from sub-streams to a master stream
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
test
.gitignore
LICENSE
README.md
bubble.js
package.json

README.md

bubble-stream-error

Description

Node module for bubbling errors from 'sub-streams' to a master stream.

Examples

var bubbleError = require('../bubble').bubble,
    fs          = require('fs'),
    zlib        = require('zlib'),
    stream      = require('stream'),
    readStream, compressStream, myStream;

readStream     = fs.createReadStream(__filename);
compressStream = zlib.createGzip();

// just a sample stream
myStream        = new require('stream').Writable();
myStream._write = function(chunk, enc, next) { next(); };

myStream.on('error', function(err) {
  console.log('myStream error:', err.message);
});

bubbleError(myStream, [readStream, compressStream]);

readStream.pipe(compressStream).pipe(myStream);

compressStream.once('data', function() {
  this.emit('error', new Error('error emitted on compressStream'));
});

// you can test also on the readStream by uncommenting below
/*
readStream.once('data', function() {
  this.emit('error', new Error('error emitted on readStream'));
});
*/

Tests

npm test

License

MIT.

Something went wrong with that request. Please try again.