mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
CommandLineInterface: Report an error immediately when writing to disk fails
This commit is contained in:
parent
c8380c25bb
commit
f50aec9334
@ -546,19 +546,12 @@ void CommandLineInterface::createFile(string const& _fileName, string const& _da
|
|||||||
|
|
||||||
string pathName = (m_options.output.dir / _fileName).string();
|
string pathName = (m_options.output.dir / _fileName).string();
|
||||||
if (fs::exists(pathName) && !m_options.output.overwriteFiles)
|
if (fs::exists(pathName) && !m_options.output.overwriteFiles)
|
||||||
{
|
solThrow(CommandLineOutputError, "Refusing to overwrite existing file \"" + pathName + "\" (use --overwrite to force).");
|
||||||
serr() << "Refusing to overwrite existing file \"" << pathName << "\" (use --overwrite to force)." << endl;
|
|
||||||
m_outputFailed = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ofstream outFile(pathName);
|
ofstream outFile(pathName);
|
||||||
outFile << _data;
|
outFile << _data;
|
||||||
if (!outFile)
|
if (!outFile)
|
||||||
{
|
solThrow(CommandLineOutputError, "Could not write to file \"" + pathName + "\".");
|
||||||
serr() << "Could not write to file \"" << pathName << "\"." << endl;
|
|
||||||
m_outputFailed = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::createJson(string const& _fileName, string const& _json)
|
void CommandLineInterface::createJson(string const& _fileName, string const& _json)
|
||||||
@ -643,9 +636,6 @@ void CommandLineInterface::processInput()
|
|||||||
compile();
|
compile();
|
||||||
outputCompilationResults();
|
outputCompilationResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_outputFailed)
|
|
||||||
solThrow(CommandLineOutputError, "Failed to write all output files to disk.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::printVersion()
|
void CommandLineInterface::printVersion()
|
||||||
@ -969,11 +959,8 @@ void CommandLineInterface::writeLinkedFiles()
|
|||||||
ofstream outFile(src.first);
|
ofstream outFile(src.first);
|
||||||
outFile << src.second;
|
outFile << src.second;
|
||||||
if (!outFile)
|
if (!outFile)
|
||||||
{
|
|
||||||
m_outputFailed = true;
|
|
||||||
solThrow(CommandLineOutputError, "Could not write to file " + src.first + ". Aborting.");
|
solThrow(CommandLineOutputError, "Could not write to file " + src.first + ". Aborting.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
sout() << "Linking completed." << endl;
|
sout() << "Linking completed." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,6 @@ private:
|
|||||||
std::ostream& m_sout;
|
std::ostream& m_sout;
|
||||||
std::ostream& m_serr;
|
std::ostream& m_serr;
|
||||||
bool m_hasOutput = false;
|
bool m_hasOutput = false;
|
||||||
bool m_outputFailed = false; ///< If true, creation or write to some of the output files failed.
|
|
||||||
FileReader m_fileReader;
|
FileReader m_fileReader;
|
||||||
std::optional<std::string> m_standardJsonInput;
|
std::optional<std::string> m_standardJsonInput;
|
||||||
std::unique_ptr<frontend::CompilerStack> m_compiler;
|
std::unique_ptr<frontend::CompilerStack> m_compiler;
|
||||||
|
Loading…
Reference in New Issue
Block a user