Skip to content

Error being overridden incorrectly on FS.Rename #11804

Closed
dotnet/runtime
#39768

Description

@kjpou1

While renaming a file and if one of the parent paths do not exist the error code is being overwritten to EBUSY instead of reporting the actual error:

Error no 44 Error: ENOENT Message: No such file or directory 

throw new FS.ErrnoError({{{ cDefine('EBUSY') }}});

Suggested code that returns back the original error code is the following:

        // parents must exist
        var lookup, old_dir, new_dir;
        try {
          lookup = FS.lookupPath(old_path, { parent: true });
          old_dir = lookup.node;
          lookup = FS.lookupPath(new_path, { parent: true });
          new_dir = lookup.node;
        } catch (e) {
          // do not override failing error
          if (e instanceof FS.ErrnoError)
            throw e;
          throw new FS.ErrnoError(10);
        }

Activity

  1. kripken commented on Aug 4, 2020

    @kripken
    Member

    I think that makes sense @kjpou1 , would you like to open a PR?

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