throw an error when a non-head message i pushed into a stream
This commit is contained in:
Родитель
ea73c7af68
Коммит
819c750106
|
@ -13,6 +13,14 @@ function NotImplementedError(message) {
|
|||
};
|
||||
}
|
||||
|
||||
function PushError(message) {
|
||||
this.message = message;
|
||||
this.name = "PushError";
|
||||
this.toString = function() {
|
||||
return this.name + " " + this.message;
|
||||
}
|
||||
}
|
||||
|
||||
function Node(identifier, listenType, emitType) {
|
||||
this.identifier = identifier;
|
||||
this.listenType = listenType;
|
||||
|
@ -231,10 +239,9 @@ Stream.prototype = {
|
|||
push: function _stream_push(messageType, message) {
|
||||
/*
|
||||
* Push a message down the stream, from the top
|
||||
* @returns a promise that gets resolved when all downstream tasks are done
|
||||
*/
|
||||
if (!(this.heads.hasOwnProperty(messageType) && this.listensTo.hasOwnProperty(messageType))) {
|
||||
deferred.reject("cannot push a non-head message");
|
||||
throw new PushError("cannot push a non-head message");
|
||||
}
|
||||
let handlers = this.listensTo[messageType] || [];
|
||||
//return this._launch_process(handlers, message);
|
||||
|
@ -321,3 +328,5 @@ Stream.prototype = {
|
|||
exports.Node = Node;
|
||||
exports.createNode = createNode;
|
||||
exports.Stream = Stream;
|
||||
exports.NotImplementedError = NotImplementedError;
|
||||
exports.PushError = PushError;
|
||||
|
|
Загрузка…
Ссылка в новой задаче