mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-19 16:16:48 +00:00
Slight tweaks to config parsing error handling (#1575)
This commit is contained in:
+1
-2
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user