Skip to content

Improve error handling when scanning remotes (#84) - #85

Open
komar007 wants to merge 1 commit into
9999years:mainfrom
komar007:fix_error_handling
Open

Improve error handling when scanning remotes (#84)#85
komar007 wants to merge 1 commit into
9999years:mainfrom
komar007:fix_error_handling

Conversation

@komar007

@komar007 komar007 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Also slightly improved miette error presentation by removing the Error: prefix generated by main.

Closes #84.

@komar007
komar007 force-pushed the fix_error_handling branch from f08f5a9 to f8c2c21 Compare April 2, 2026 16:58

@9999years 9999years left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hey, sorry it's taken me so long to get to this, work has been hectic lately. Some stylistic changes but the underlying behavior change (surfacing errors from Gerrit::new) looks good.

Comment thread src/git.rs Outdated
Comment thread src/main.rs Outdated
fn main() -> miette::Result<()> {
fn main() {
if let Err(error) = run() {
eprint!("{error:?}");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What's this look like in practice? Is it still colored and nicely formatted? I'd also like to keep the error in the logs in some format. (This change should probably be a separate PR.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, I'll move that to a different PR.

The change looks like this:
image
vs
image

So basically:

  • alignment is fixed because "Error:" is not printed in the first line,
  • no extra line at the end of the outout.

@komar007 komar007 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No worries, I adjusted the PR according to your review.

Comment thread src/git.rs
}
}

pub fn gerrit(&self, gerrit_remote_name: Option<&str>) -> miette::Result<GerritGitRemote> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW, can we get rid of gerrit_remote_name? It is always None, and if it weren't, the logic is weird - instead we could immediately query remote_url on it and immediately fail if that fails. Currently this path has an unnecessary race condition where the remote exists while self.remotes(), but disappears before self.remote_url().

Comment thread src/main.rs Outdated
fn main() -> miette::Result<()> {
fn main() {
if let Err(error) = run() {
eprint!("{error:?}");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, I'll move that to a different PR.

The change looks like this:
image
vs
image

So basically:

  • alignment is fixed because "Error:" is not printed in the first line,
  • no extra line at the end of the outout.

Extra changes:
- failure to find remote url -> continue to next remote (instead of err),
- failure in Gerrit::new (cache error) -> err immediately (the next
  remote is unlikely to succeed).
@komar007
komar007 force-pushed the fix_error_handling branch from f8c2c21 to ec7fb82 Compare July 26, 2026 10:45
@komar007
komar007 requested a review from 9999years July 26, 2026 10:50
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.

confusing error message when git-gr has no access to cache

2 participants