Throw better error if lockfile is not writable.
This commit is contained in:
parent
f59f9ebd5f
commit
250195924e
|
@ -229,8 +229,16 @@ bool create_lockfile()
|
|||
|
||||
ofstream file;
|
||||
file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||
file.open(lockfile);
|
||||
file << getpid();
|
||||
try
|
||||
{
|
||||
file.open(lockfile);
|
||||
file << getpid();
|
||||
}
|
||||
catch (const std::ofstream::failure &e)
|
||||
{
|
||||
const auto msg{string("Could not write lockfile: ") += e.what()};
|
||||
throw std::runtime_error{msg.c_str()};
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Reference in New Issue