mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Create BadInput exception hierarchy and make exceptions used by Phaser more specific
This commit is contained in:
parent
53803801f7
commit
f05a07d0cc
@ -22,6 +22,9 @@
|
||||
namespace solidity::phaser
|
||||
{
|
||||
|
||||
struct InvalidProgram: virtual util::Exception {};
|
||||
struct BadInput: virtual util::Exception {};
|
||||
struct InvalidProgram: virtual BadInput {};
|
||||
struct NoInputFiles: virtual BadInput {};
|
||||
struct MissingFile: virtual BadInput {};
|
||||
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ Program ProgramFactory::build(Options const& _options)
|
||||
|
||||
CharStream ProgramFactory::loadSource(string const& _sourcePath)
|
||||
{
|
||||
assertThrow(boost::filesystem::exists(_sourcePath), InvalidProgram, "Source file does not exist");
|
||||
assertThrow(boost::filesystem::exists(_sourcePath), MissingFile, "Source file does not exist: " + _sourcePath);
|
||||
|
||||
string sourceCode = readFileAsString(_sourcePath);
|
||||
return CharStream(sourceCode, _sourcePath);
|
||||
@ -216,10 +216,7 @@ Phaser::CommandLineParsingResult Phaser::parseCommandLine(int _argc, char** _arg
|
||||
}
|
||||
|
||||
if (arguments.count("input-file") == 0)
|
||||
{
|
||||
cerr << "Missing argument: input-file." << endl;
|
||||
return {1, move(arguments)};
|
||||
}
|
||||
assertThrow(false, NoInputFiles, "Missing argument: input-file.");
|
||||
|
||||
return {0, arguments};
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ int main(int argc, char** argv)
|
||||
std::cerr << "ERROR: " << exception.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
catch (solidity::phaser::InvalidProgram const& exception)
|
||||
catch (solidity::phaser::BadInput const& exception)
|
||||
{
|
||||
// Error in the input data. One of the provided programs contains errors and could not be loaded.
|
||||
// Handle it and exit.
|
||||
// Bad input data. Syntax errors in the input program, semantic errors in command-line
|
||||
// parameters, etc.
|
||||
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ERROR: " << exception.what() << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user