Hmm... I tried
var fs = require("fs")
var writable = fs.createWriteStream("file.txt")
writable.on("error", function(err){console.log(err)})
writable.end()
writable.write("hello\n")
registering the error listener BEFORE the .end(), and it works ok
On Thu, Sep 5, 2013 at 6:01 PM, Oscar Torrente Artero <[email protected]>wrote:
> Hello.
>
> This so simple code breaks:
>
> var fs = require("fs")
> var writable = fs.createWriteStream("file.txt")
> writable.end()
> writable.write("hello\n")
> writable.on("error", function(err){console.log(err)})
>
> The reason is simple: method end() cannot be executed before method
> write(). But, why isn't error message displayed? Error event is ignored, so
> the program uglily crashes. In WriteStream docs there is no mention to
> "error" event, but I supposed that it would be inherited from EventEmitter
> prototype (like ReadStream, which does have "error" event, and it's
> mentioned in its docs) . Isn't it true?
>
> Thanks!!
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.