Closed Thimoteus closed 8 years ago
:scream: this definitely shouldn't happen.
Perhaps we incorrectly assumed the error would be thrown immediately if fs.statSync
failed? I'm not at my laptop right now but does it work in node using JS directly if you try to wrap fs.statSync
in a try...catch block?
It seems to work as intended in node:
> try {
... fs.statSync('./something');
... } catch (e) {
... console.log(e);
... }
{ [Error: ENOENT: no such file or directory, stat './something']
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: './something' }
Fixed by https://github.com/purescript-node/purescript-node-fs/commit/b1a99f855a245e1031a91e33ff218b5531c0033e, released in 0.9.3. Thanks for the report! :)
Oops, I meant v0.10.1. I really need to get on and implement pulp version
to protect me from myself.
This is a failing example that's close to what I was using.
I'm not sure if the problem is with
stat
orcatchException
, but essentially this is the problem:You can use
catchException
to discharge anEXCEPTION
assumption from your program. Great! If we use enoughcatchException
s, the compiler tells us (assuming everything was well-typed) that our program won't have any uncaught exceptions at runtime.Except it does.
catchException
doesn't ... catch the exception ... when usingstat
on a path that doesn't exist.This threw me for a loop since I was assuming that uncaught runtime exceptions wouldn't happen.