diff --git a/lib/file.js b/lib/file.js index e34c10e4..483d1257 100644 --- a/lib/file.js +++ b/lib/file.js @@ -31,7 +31,11 @@ module.exports = File; util.inherits(File, EventEmitter); File.prototype.open = function() { + var self = this; this._writeStream = new WriteStream(this.path); + this._writeStream.on('error', function(err) { + self.emit('error', err); + }) }; File.prototype.toJSON = function() { diff --git a/lib/incoming_form.js b/lib/incoming_form.js index 27b9aedb..29de02d1 100644 --- a/lib/incoming_form.js +++ b/lib/incoming_form.js @@ -229,6 +229,10 @@ IncomingForm.prototype.handlePart = function(part) { self._maybeEnd(); }); }); + + file.on('error', function(err) { + self.emit('error', err); + }); }; function dummyParser(self) {