Refactor decoding errors with more improvements #131
Labels
config
TOML configuration, config-related CLI options
good first issue
Good for newcomers
hacktoberfest
https://hacktoberfest.com/
Milestone
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_STRING
orSTRING_TYPE
. It's a hack to reusetoml::Value
for 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_name
is not a table. Currently we return emptyAssetName
but 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_key
doesn'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
DecodeError
when iterating through the map. We expect all tools to be tables. So we should iterate through the map, filter out expected keys (proxy
andstore_directory
) and throw an error otherwisetool-sync/src/config/toml.rs
Lines 124 to 126 in f345444
The text was updated successfully, but these errors were encountered: