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

fix: improve error handling for URLs without scheme #674

Merged
merged 2 commits into from
Jan 25, 2025

Conversation

grainme
Copy link
Contributor

@grainme grainme commented Jan 24, 2025

While using oha, I found that it panics when given a URL without a scheme (e.g., localhost:4221 instead of http://localhost:4221).

Instead of a friendly error message, we get this panic:
image

Proposed Change

I tried to make this a bit more user-friendly by:

  • Replace unwrap() with some error handling
  • Set exit code on failure

I'm new to the project, so please let me know if there's a better way to handle this.

- Replace unwrap() with some error handling
- Print user-friendly error message
- Set exit code on failure

This change makes the tool more user-friendly by providing error messages instead of panicking.
@grainme grainme changed the title fix: improve error handling in main function fix: improve error handling for URLs without scheme Jan 24, 2025
Copy link
Owner

@hatoo hatoo left a comment

Choose a reason for hiding this comment

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

Nice catch!

I added a small review.
Thank you.

src/main.rs Outdated Show resolved Hide resolved
@hatoo hatoo merged commit 5aaaca3 into hatoo:master Jan 25, 2025
18 checks passed
@hatoo
Copy link
Owner

hatoo commented Jan 25, 2025

👍

@Mua-th
Copy link

Mua-th commented Jan 25, 2025

nas khdama lahoma barik hhh

@grainme grainme deleted the fix-graceful-url-parsing branch January 25, 2025 19:35
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.

3 participants