-
-
Notifications
You must be signed in to change notification settings - Fork 22
Refactor decoding errors with more improvements #131
Copy link
Copy link
Open
Labels
configTOML configuration, config-related CLI optionsTOML configuration, config-related CLI optionsgood first issueGood for newcomersGood for newcomershacktoberfesthttps://hacktoberfest.com/https://hacktoberfest.com/
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
configTOML configuration, config-related CLI optionsTOML configuration, config-related CLI optionsgood first issueGood for newcomersGood for newcomershacktoberfesthttps://hacktoberfest.com/https://hacktoberfest.com/
Custom decoding errors were implemented in the following PR:
This issue is about some minor improvements to the implementation so they can be done separately:
Value::String("some value")intoconst EXPECTED_STRINGorSTRING_TYPE. It's a hack to reusetoml::Valuefor types of expected values. We can move them into top-level constants for easier reuse in the future:tool-sync/src/config/toml.rs
Line 106 in f345444
asset_nameis not a table. Currently we return emptyAssetNamebut we should provide a custom error when it's something likeasset_name = "x86_64_unknown_linux_musl". Implement a similar constant to the previous task for stringtool-sync/src/config/toml.rs
Lines 163 to 168 in f345444
str_by_keydoesn't seeString. The function returnsOption<String>. Its type should be changed toResult<Option<String>, DecodeError>and its name should be changed tooptional_str_by_key. And this function should throw an error when it sees something besides string.tool-sync/src/config/toml.rs
Lines 184 to 186 in f345444
DecodeErrorwhen iterating through the map. We expect all tools to be tables. So we should iterate through the map, filter out expected keys (proxyandstore_directory) and throw an error otherwisetool-sync/src/config/toml.rs
Lines 124 to 126 in f345444