Skip to content
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

flags: better error message on invalid reload url #4729

Closed

Conversation

kevinkassimo
Copy link
Contributor

Noticed this during slides prep.

Before:

$ deno -r=123 https://deno.land/std/examples/welcome.ts
thread 'main' panicked at 'Bad Url: 123', cli/flags.rs:1238:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

./target/debug/deno -r=123 https://deno.land/std/examples/welcome.ts
Unable to resolve URL '123': relative URL without a base

@@ -1232,17 +1233,15 @@ fn permission_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
}

// TODO(ry) move this to utility module and add test.
/// Strips fragment part of URL. Panics on bad URL.
/// Strips fragment part of URL.
pub fn resolve_urls(urls: Vec<String>) -> Vec<String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should rather return Result<Vec<String>, Error>; otherwise there's no way to write unit test for failing URL - process will exit instead of erroring and running other tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We shouldn't make it more ergonomic to process::exit(1), instead we should be removing those.

@kevinkassimo I appreciate the patch as always - but I'd rather the ugly panic than introducing this exit-macro. Closing without merge.

@ry ry closed this Apr 13, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants