Skip to content

Better error message when changing to a directory that doesn't exist #109

Description

@jyn514

Currently, the error looks like this:

thread 'reports_broken_links' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/assert_cmd-1.0.1/src/assert.rs:59:36

The actual issue is that I tried to change to a directory that doesn't exist:

	Command::cargo_bin("cargo-deadlinks")
		.unwrap()
		.arg("deadlinks")
		.current_dir("./tests/broken_links")  // this directory does not exist

This is made worse by the backtrace, which points to the wrong line:

   3: core::result::Result<T,E>::unwrap
             at /home/joshua/.local/lib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:973
   4: <&mut std::process::Command as assert_cmd::assert::OutputAssertExt>::assert
             at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/assert_cmd-1.0.1/src/assert.rs:59
   5: broken_links::reports_broken_links
             at ./tests/broken_links.rs:9  // this is `Command::cargo_bin`, not `current_dir`

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions