switch to done.reject for error handling

This commit is contained in:
2016-09-25 19:41:12 +02:00
parent 224b39f0a6
commit 084a47096d
3 changed files with 7 additions and 27 deletions

View File

@ -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)
}