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

Localize ParseControlErrorInfo. #521

Merged
merged 5 commits into from
May 25, 2022

Conversation

BillyONeal
Copy link
Member

@BillyONeal BillyONeal commented Apr 22, 2022

  • Teach ParseControlError info the to_string protocol.
  • Localize that output.
  • Implement ParseControlErrorInfo::format_errors with that. Note that this is a behavior change, since errors are grouped by file rather than by error type.

Copy link
Contributor

@ras0219-msft ras0219-msft left a comment

Choose a reason for hiding this comment

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

This does have significant functional impact on the output (it is now sorted by port instead of by error type), however I think this is an ok change.

Given that the only remaining reason for ParseControlErrorInfo to exist after this (compared to just using a LocalizedString) is to contain the single bit of "Was there a CONTROL file with extra fields?", we may want to consider simplifying the pathway and just linking users to online documentation.

include/vcpkg/paragraphparser.h Outdated Show resolved Hide resolved
include/vcpkg/paragraphparser.h Outdated Show resolved Hide resolved
@BillyONeal
Copy link
Member Author

After some discussion in person I'm not sure I'm happy with this change right now, so setting to draft.

@BillyONeal BillyONeal marked this pull request as draft April 27, 2022 00:35
@ras0219-msft
Copy link
Contributor

I've partially moved the needle on this in #516 (3ff332c). It preserves existing behavior while also creating an approximate api of std::string format(View<ParseControlErrorInfo>).

@BillyONeal
Copy link
Member Author

Unfortunately #516 damaged what this PR is trying to do beyond repair.

@BillyONeal BillyONeal closed this May 23, 2022
@BillyONeal BillyONeal reopened this May 24, 2022
@BillyONeal
Copy link
Member Author

Unfortunately #516 damaged what this PR is trying to do beyond repair.

Upon further reflection I think this is salvagable.

# Conflicts:
#	include/vcpkg/paragraphparser.h
#	locales/messages.en.json
#	locales/messages.json
#	src/vcpkg/sourceparagraph.cpp
@BillyONeal
Copy link
Member Author

After some discussion in person I'm not sure I'm happy with this change right now, so setting to draft.

I tried to do what we discussed that led me to drafting this, eliminating ParseControlErrorInfo entirely. Unfortunately that change ends up being HUGE and I think this moves the needle in a positive direction, so undrafting.

@BillyONeal BillyONeal marked this pull request as ready for review May 25, 2022 00:44
@BillyONeal BillyONeal requested a review from ras0219-msft May 25, 2022 00:49
@BillyONeal
Copy link
Member Author

Upon reflection I think we should print everything in the error block in the error color rather than looking for "error:" as was added in #516 but I didn't change that for now.

@@ -147,7 +147,7 @@ namespace vcpkg

if (auto error = parser.get_error())
{
return msg::format(msgGitUnexpectedCommandOutput).append_raw(error->format());
return msg::format(msgGitUnexpectedCommandOutput).append_raw(error->to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return msg::format(msgGitUnexpectedCommandOutput).append_raw(error->to_string());
return msg::format(msgGitUnexpectedCommandOutput).append_raw("\n").append_raw(error->to_string());

I think this needs a newline because error->to_string() expects to begin at start of line

Copy link
Contributor

@ras0219-msft ras0219-msft May 25, 2022

Choose a reason for hiding this comment

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

Also, it would be nice if append_raw() would eat anything that can be Strings::append()'d

Noticed that this is actually a smart pointer, so Strings::append() wouldn't recognize it anyway.

DECLARE_AND_REGISTER_MESSAGE(ParseControlErrorInfoWhileLoading,
(msg::path, msg::error_msg),
"",
"while loading {path}: {error_msg}");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one should not contain error_msg -- it should be appended at the call site. I believe error_msg is a multiline blob with headers, such as:

../path/to/file:10: error: identifier not valid

(msg::path),
"",
"there are invalid fields in the control or manifest file of {path}.\nThe following fields were not expected:");
DECLARE_AND_REGISTER_MESSAGE(ParseControlErrorInfoEntry, (msg::path, msg::error_msg), "", "In {path}: {error_msg}");
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't an error_msg, this is a list.

@BillyONeal BillyONeal merged commit 8f176a5 into microsoft:main May 25, 2022
@BillyONeal BillyONeal deleted the localize-errors branch May 25, 2022 23:46
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.

2 participants