From 084a47096d024ffeb3a2078f39a04f330ee2668d Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Sun, 25 Sep 2016 19:41:12 +0200 Subject: [PATCH] switch to done.reject for error handling --- dist/index.d.ts | 5 ----- dist/index.js | 15 ++++----------- ts/index.ts | 14 +++----------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index a19c96b..a581d6d 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -15,17 +15,12 @@ export interface ICustomEventObject { */ export declare class Smartstream { private streamArray; - private errorFunction; private customEventObjectArray; private streamStartedDeferred; /** * constructor */ constructor(streamArrayArg: any[]); - /** - * attach an error handler to the stream to prevent throwing - */ - onError(errorFunctionArg: IErrorFunction): void; /** * make something with the stream itself */ diff --git a/dist/index.js b/dist/index.js index 80dec5e..6bf7920 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9,17 +9,10 @@ class Smartstream { */ constructor(streamArrayArg) { this.streamArray = []; - this.errorFunction = null; this.customEventObjectArray = []; this.streamStartedDeferred = plugins.q.defer(); this.streamArray = streamArrayArg; } - /** - * attach an error handler to the stream to prevent throwing - */ - onError(errorFunctionArg) { - this.errorFunction = errorFunctionArg; - } /** * make something with the stream itself */ @@ -53,9 +46,9 @@ class Smartstream { if (firstIteration === true) { finalStream = stream; } - if (this.errorFunction !== null) { - stream.on('error', this.errorFunction); - } + stream.on('error', (err) => { + done.reject(err); + }); for (let customEventObject of this.customEventObjectArray) { stream.on(customEventObject.eventName, customEventObject.eventFunction); } @@ -78,4 +71,4 @@ class Smartstream { } } exports.Smartstream = Smartstream; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsaURBQWdEO0FBZWhEOztHQUVHO0FBQ0g7SUFNSTs7T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UFXLEdBQUcsV0FBVyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtZQUMxQyxDQUFDO1lBQ0QsY0FBYyxHQUFHLEtBQUssQ0FBQTtRQUMxQixDQUFDO1FBRUQsSUFBSSxDQUFDLHFCQUFxQixDQUFDLE9BQU8sRUFBRSxDQUFBO1FBRXBDLFdBQVcsQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFDO1lBQ2pCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNsQixDQUFDLENBQUMsQ0FBQTtRQUNGLFdBQVcsQ0FBQyxFQUFFLENBQUMsT0FBTyxFQUFDO1lBQ25CLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNsQixDQUFDLENBQUMsQ0FBQTtRQUNGLFdBQVcsQ0FBQyxFQUFFLENBQUMsUUFBUSxFQUFDO1lBQ3BCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNsQixDQUFDLENBQUMsQ0FBQTtRQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7Q0FDSjtBQXhFRCxrQ0F3RUMifQ== \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index 627d144..392f598 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -18,7 +18,6 @@ export interface ICustomEventObject { */ export class Smartstream { private streamArray = [] - private errorFunction: IErrorFunction = null private customEventObjectArray: ICustomEventObject[] = [] private streamStartedDeferred = plugins.q.defer() @@ -29,13 +28,6 @@ export class Smartstream { this.streamArray = streamArrayArg } - /** - * attach an error handler to the stream to prevent throwing - */ - onError(errorFunctionArg: IErrorFunction) { - this.errorFunction = errorFunctionArg - } - /** * make something with the stream itself */ @@ -71,9 +63,9 @@ export class Smartstream { if (firstIteration === true) { finalStream = stream } - if (this.errorFunction !== null) { - stream.on('error', this.errorFunction) - } + stream.on('error', (err) => { + done.reject(err) + }) for (let customEventObject of this.customEventObjectArray) { stream.on(customEventObject.eventName, customEventObject.eventFunction) }