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

Exception handling in SettingsService #1731

Open
jp-weber opened this issue Jun 27, 2020 · 3 comments
Open

Exception handling in SettingsService #1731

jp-weber opened this issue Jun 27, 2020 · 3 comments

Comments

@jp-weber
Copy link
Member

jp-weber commented Jun 27, 2020

Currently possible exceptions are not directly handled and caught in the SettingsService. Would it be better to handle them here?

example Settings/Adapters/LocalFileSettingsAdapter.cs
new

        public (bool successful, string result) ReadString(string key)
        {
            if (_container.Values.ContainsKey(key))
            {
                return (true, _container.Values[key].ToString());
            }
            else
            {
                return (false, string.Empty);
            }
        }

old

public string ReadString(string key)
            => _container.Values[key].ToString();

I have already implemented many things in my fork:
https://github.com/jp-weber/Template10/tree/master/Source/Template10.Extras/Services/Settings

@JerryNixon
Copy link
Member

@jp-weber how about creating a repo dedicated to Settings? Windows-XAML/Template10.SettingsService. Interested? THe many things you have already done are pretty handy for developers and we could brand it Template 10 and pub to Nuget.

@jp-weber
Copy link
Member Author

@JerryNixon Yes I would like to do that 😀

@JerryNixon
Copy link
Member

I wonder if bool TryRead<T>(string key, out T value) would be a better signature.

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

No branches or pull requests

2 participants