Slight tweaks to config parsing error handling (#1575)

This commit is contained in:
trapexit
2025-11-13 16:05:03 -06:00
committed by GitHub
parent af1edadf72
commit 01973214bf
3 changed files with 19 additions and 7 deletions
+1 -2
View File
@@ -81,9 +81,8 @@ namespace l
u64 offset;
offset = s_.find_first_not_of("+<>-=");
if (offset == std::string::npos) {
if(offset == std::string::npos)
return;
}
if(offset > 1)
offset = 2;
+3
View File
@@ -557,6 +557,9 @@ Config::Err::to_string() const
case ELOOP:
s = "too many levels of config";
break;
case ENOENT:
s = "no value set";
break;
default:
s = strerror(err);
break;
+15 -5
View File
@@ -196,7 +196,10 @@ _option_processor(void *data_,
}
else
{
cfg.branches.from_string("+>" + prev_nonopt);
int rv;
rv = cfg.branches.from_string("+>" + prev_nonopt);
if(rv < 0)
cfg.errs.push_back({-rv,prev_nonopt});
prev_nonopt = arg_;
}
}
@@ -315,15 +318,22 @@ namespace options
if(!prev_nonopt.empty())
{
if(cfg.mountpoint.empty())
cfg.mountpoint = prev_nonopt;
{
cfg.mountpoint = prev_nonopt;
}
else
cfg.branches.from_string("+>" + prev_nonopt);
{
int rv;
rv = cfg.branches.from_string("+>" + prev_nonopt);
if(rv < 0)
cfg.errs.push_back({-rv,prev_nonopt});
}
}
if(cfg.branches->empty())
cfg.errs.push_back({EINVAL,"branches not set"});
cfg.errs.push_back({ENOENT,"branches not set"});
if(cfg.mountpoint.empty())
cfg.errs.push_back({EINVAL,"mountpoint not set"});
cfg.errs.push_back({ENOENT,"mountpoint not set"});
if(!cfg.errs.empty())
return;