mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10199 from ethereum/readfile
[CLI] Improve error handling of missing/unwriteable files
This commit is contained in:
@@ -0,0 +1 @@
|
||||
--standard-json
|
||||
@@ -0,0 +1 @@
|
||||
File not found: standard_file_not_found/input.sol
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
+12
-1
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <libsolutil/CommonIO.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <libyul/AsmAnalysis.h>
|
||||
@@ -243,8 +244,18 @@ Allowed options)",
|
||||
}
|
||||
|
||||
string input;
|
||||
try
|
||||
{
|
||||
input = readFileAsString(arguments["input-file"].as<string>());
|
||||
}
|
||||
catch (FileNotFound const& _exception)
|
||||
{
|
||||
cerr << "File not found:" << _exception.comment() << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arguments.count("input-file"))
|
||||
YulOpti{}.runInteractive(readFileAsString(arguments["input-file"].as<string>()));
|
||||
YulOpti{}.runInteractive(input);
|
||||
else
|
||||
cout << options;
|
||||
|
||||
|
||||
+12
-2
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <libsolutil/CommonIO.h>
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
@@ -137,10 +138,19 @@ Allowed options)",
|
||||
else
|
||||
{
|
||||
string input;
|
||||
|
||||
if (arguments.count("input-file"))
|
||||
for (string path: arguments["input-file"].as<vector<string>>())
|
||||
input += readFileAsString(path);
|
||||
{
|
||||
try
|
||||
{
|
||||
input += readFileAsString(path);
|
||||
}
|
||||
catch (FileNotFound const&)
|
||||
{
|
||||
cerr << "File not found: " << path << endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
input = readStandardInput();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user