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

Display a warning for when we fail to write to the settings file #7950

Merged
5 commits merged into from Oct 23, 2020

Conversation

PankajBhojwani
Copy link
Contributor

@PankajBhojwani PankajBhojwani commented Oct 16, 2020

We wrap the call to _WriteSettings in
CascadiaSettingsSerialization.cpp in a try/catch block, and if we
catch an error we append a warning telling the user to check the
permissions on their settings file.

Closes #7727

@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Oct 16, 2020
@PankajBhojwani
Copy link
Contributor Author

Alternative implementation:

We wrap the call to _WriteSettings in CascadiaSettingsSerialization.cpp in a try/catch block, and if we catch an error we throw a SettingsTypedDeserializationException with a message about what happened.

This would mean we should update the InitialJsonParseErrorText resource string to not talk about syntax errors though.

@miniksa
Copy link
Member

miniksa commented Oct 19, 2020

Alternative implementation:

We wrap the call to _WriteSettings in CascadiaSettingsSerialization.cpp in a try/catch block, and if we catch an error we throw a SettingsTypedDeserializationException with a message about what happened.

This would mean we should update the InitialJsonParseErrorText resource string to not talk about syntax errors though.

I kind of like this better. Right now my concern with how you have it written is that you're only keying off the one E_ACCESSDENIED exception. I feel like there are at least half a dozen errors that could come out of just reading the file and one or more of those could possibly overlap with the deserialization/json library's set of errors.

It might just be nicer to adjust that existing json error message to take a format substring inside it and let the exception, as you describe, provide the details as it throws it up the stack from either the file load or the json work itself.

}
catch (...)
{
throw SettingsTypedDeserializationException{ winrt::to_string((RS_(L"WriteSettingsFailed"))) };
Copy link
Member

Choose a reason for hiding this comment

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

I'm not in love with this one -- SettingsTypedDeserializationException taking a string is because of laziness, not to signal that it is the right way to emit settings error text. I'd rather surface it through the existing mechanisms for settings warnings (which we do have!), if at all possible. Warnings are allocated resource strings in TerminalApp instead of TerminalSettingsModel, admittedly, but there's already code that handles displaying a dialog with a number of warnings in it 😄

Copy link
Member

Choose a reason for hiding this comment

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

I know this conflicts with what @miniksa asked for, but we've got a long tradition of swallowing exceptions and presenting them to the user as "well something weird happened" here on Terminal. At least sending it up as a warning code (not an error!) DOES NOT discard the entire settings load operation!

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 with the above. Failing to write the file doesn't seem like the kind of thing that makes the entire settings unusable - we've got perfectly valid settings in fact, we just can't update the dynamic profiles. That's not world-ending, we can still run with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to a warning now!

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 21, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 21, 2020
@PankajBhojwani PankajBhojwani changed the title Display a more appropriate error message for when we fail to write to the settings file Display a more appropriate warning for when we fail to write to the settings file Oct 21, 2020
@PankajBhojwani PankajBhojwani changed the title Display a more appropriate warning for when we fail to write to the settings file Display a warning for when we fail to write to the settings file Oct 21, 2020
Copy link
Member

@zadjii-msft zadjii-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 looks like how I'd do it, thanks!

@microsoft-github-updates microsoft-github-updates bot changed the base branch from master to main October 22, 2020 00:27
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Love it

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 23, 2020
@ghost
Copy link

ghost commented Oct 23, 2020

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 16b8ea1 into main Oct 23, 2020
@ghost ghost deleted the dev/pabhoj/read_only_settings branch October 23, 2020 00:21
DHowett pushed a commit that referenced this pull request Oct 27, 2020
We wrap the call to `_WriteSettings` in
`CascadiaSettingsSerialization.cpp` in a try/catch block, and if we
catch an error we append a warning telling the user to check the
permissions on their settings file.

Closes #7727

(cherry picked from commit 16b8ea1)
@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal v1.4.3141.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal shouldn't treat read-only settings as an error reading settings
4 participants