switch to done.reject for error handling
This commit is contained in:
14
ts/index.ts
14
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user