mirror of https://github.com/nodejs/node.git
Closes GH-85 Emit error rather than throwing.
Since "error" events will throw when unhandled anyhow, it makes no sense to throw from an EventEmitter's method, especially for such a minor misdemeanor as attempting to write to a non-writable stream.pull/22966/head
parent
2cfe7b847d
commit
f3d364122d
|
@ -1027,7 +1027,8 @@ WriteStream.prototype.flush = function() {
|
|||
|
||||
WriteStream.prototype.write = function(data) {
|
||||
if (!this.writable) {
|
||||
throw new Error('stream not writable');
|
||||
this.emit("error", new Error('stream not writable'));
|
||||
return false;
|
||||
}
|
||||
|
||||
this.drainable = true;
|
||||
|
|
|
@ -99,7 +99,8 @@ WriteStream.prototype.isTTY = true;
|
|||
|
||||
WriteStream.prototype.write = function(data, encoding) {
|
||||
if (!this.writable) {
|
||||
throw new Error('stream not writable');
|
||||
this.emit("error", new Error('stream not writable'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(data)) {
|
||||
|
|
Loading…
Reference in New Issue