Skip to content

stat can result in unexpected runtime failures #27

Closed

Description

@Thimoteus

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.

Activity

  1. hdgarrood commented on Mar 3, 2016

    @hdgarrood
    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?

  2. Thimoteus commented on Mar 3, 2016

    @Thimoteus
    ContributorAuthor

    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' }
  3. hdgarrood commented on Mar 5, 2016

    @hdgarrood
    Member

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

  4. hdgarrood commented on Mar 5, 2016

    @hdgarrood
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions