Skip to content

Commit

Permalink
Tolerate non-Errors to allow for special exit signals and compatibili…
Browse files Browse the repository at this point in the history
…ty with other flow control paradigms.
  • Loading branch information
mikermcneil committed Nov 21, 2017
1 parent 13a64fc commit 1d0878d
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions lib/waterline/methods/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Module dependencies
*/

var util = require('util');
var _ = require('@sailshq/lodash');
var async = require('async');
var flaverr = require('flaverr');
Expand Down Expand Up @@ -425,21 +424,8 @@ module.exports = function stream( /* criteria?, eachRecordFn?, explicitCbMaybe?,

})(function _afterCallingIteratee(err){
if (err) {

// Since this `err` might have come from the userland iteratee,
// we can't completely trust it. So check it out, and if it's
// not one already, convert `err` into Error instance.
if (!_.isError(err)) {
if (_.isString(err)) {
err = new Error(err);
}
else {
err = new Error(util.inspect(err, {depth:5}));
}
}//>-

return next(err);
}//--•
}

// Increment the batch counter.
i++;
Expand Down

0 comments on commit 1d0878d

Please sign in to comment.