utils: readCompleteFile(): Throw exception if file can't be opened
This commit is contained in:
parent
f7cf06cdd5
commit
16c352c6af
@ -138,6 +138,10 @@ std::string utils::readCompleteFile(std::string_view filepath)
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::fstream stream(std::string{filepath});
|
std::fstream stream(std::string{filepath});
|
||||||
|
if(!stream.is_open())
|
||||||
|
{
|
||||||
|
throw std::runtime_error("stream is not open");
|
||||||
|
}
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << stream.rdbuf();
|
ss << stream.rdbuf();
|
||||||
std::string content = ss.str();
|
std::string content = ss.str();
|
||||||
|
Loading…
Reference in New Issue
Block a user