Skip to content

stat can result in unexpected runtime failures #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Thimoteus opened this issue Mar 3, 2016 · 4 comments
Closed

stat can result in unexpected runtime failures #27

Thimoteus opened this issue Mar 3, 2016 · 4 comments

Comments

@Thimoteus
Copy link
Contributor

This is a failing example that's close to what I was using.

I'm not sure if the problem is with stat or catchException, but essentially this is the problem:

You can use catchException to discharge an EXCEPTION assumption from your program. Great! If we use enough catchExceptions, 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 using stat on a path that doesn't exist.

This threw me for a loop since I was assuming that uncaught runtime exceptions wouldn't happen.

@hdgarrood
Copy link
Member

😱 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?

@Thimoteus
Copy link
Contributor Author

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' }

@hdgarrood
Copy link
Member

Fixed by b1a99f8, released in 0.9.3. Thanks for the report! :)

@hdgarrood
Copy link
Member

Oops, I meant v0.10.1. I really need to get on and implement pulp version to protect me from myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants