Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Propagate build errors using window/showMessage #657

Merged
merged 2 commits into from
Mar 2, 2018

Conversation

algesten
Copy link
Contributor

@algesten algesten commented Jan 14, 2018

This is based off #653 and needs to land after that.

Currently build errors go to the logs, but does not show up in the UI. This PR fixes that so that the first encountered build error will be notified using window/showMessage. No further build errors will be propagated until the error state has cleared since a build attempt happens on every keystroke.

screen shot 2018-01-14 at 12 28 20

@nrc
Copy link
Member

nrc commented Jan 15, 2018

To clarify, this is meant to only use showMessage when there was an unexpected error during the build, rather than a compilation error?

@algesten
Copy link
Contributor Author

Yes. When cargo bombs out.

@algesten
Copy link
Contributor Author

Technically should also do it when rustc does for plan.rs, but there doesn't seem to be an error case there right now. Maybe it just always works.

@algesten
Copy link
Contributor Author

@nrc This PR was made redundant by the work you did a few days ago. I still think there's a point to keep the error messages concise against VSCode (because it will only show one single line), so I redid this PR to only do some of that minor formatting.

fn notify_end_diagnostics(&self);
fn notify_error_diagnostics(&self, msg: &str);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this rename is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. i keep the name

};
let msg = format!("Cargo failed: {}{}", err, stdout_msg);
info!("{}", msg);
BuildResult::Err(msg, None)
Copy link
Member

Choose a reason for hiding this comment

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

This message is longer than previously, so I don't think it makes it more concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really? I mean I tested this live (see screen grab at the top).

The current code would show:

cargo failed
cause: Could not compile `getopts`.
stdout:

Which has two problems:

  1. VSCode only shows one line. So the user would only see cargo failed, not the cause.
  2. It prints stdout: regardless of there being anything to show there.

The proposed change would do

Cargo failed: Could not compile `getopts`.

And if there is a stdout pad that on inside parentheses. I maintain this is a better solution.

format!("({})", stdout)
};
let msg = format!("Cargo failed: {}{}", err, stdout_msg);
info!("{}", msg);
Copy link
Member

Choose a reason for hiding this comment

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

I try to use debug for messages where something has gone wrong.

// It's not a good idea to make a long message here, the output in
// VSCode is one single line, and it's important to capture the
// root cause.
// let msg = format!("There was an error trying to build, RLS features will be limited: {}", cause);
Copy link
Member

Choose a reason for hiding this comment

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

Just delete rather than commenting out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// VSCode is one single line, and it's important to capture the
// root cause.
// let msg = format!("There was an error trying to build, RLS features will be limited: {}", cause);
self.notifier.notify_build_error_diagnostics(cause);
Copy link
Member

Choose a reason for hiding this comment

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

It sounds like a good idea to make the message shorter, but we probably need some boilerplate here - the cause message might not be very informational if it is an internal error message and we should make clear to the user that something failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's a hard balance. I think Cargo failed: that comes from the underlying error addresses that somewhat. I don't know if there is some other mechanism we can use to provide more details to the user?

@algesten
Copy link
Contributor Author

@nrc I pushed the changes I agreed with and discussed the rest above.

@nrc nrc merged commit b113fcd into rust-lang:master Mar 2, 2018
@nrc
Copy link
Member

nrc commented Mar 2, 2018

Thanks for the changes!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants