mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move exception handlers from CommandLineInterface to main()
This commit is contained in:
parent
298af55cc5
commit
e13dc5084d
@ -699,30 +699,6 @@ bool CommandLineInterface::compile()
|
||||
formatter.printExceptionInformation(_exception, "Compiler error");
|
||||
return false;
|
||||
}
|
||||
catch (InternalCompilerError const& _exception)
|
||||
{
|
||||
serr() <<
|
||||
"Internal compiler error during compilation:" <<
|
||||
endl <<
|
||||
boost::diagnostic_information(_exception);
|
||||
return false;
|
||||
}
|
||||
catch (UnimplementedFeatureError const& _exception)
|
||||
{
|
||||
serr() <<
|
||||
"Unimplemented feature:" <<
|
||||
endl <<
|
||||
boost::diagnostic_information(_exception);
|
||||
return false;
|
||||
}
|
||||
catch (smtutil::SMTLogicError const& _exception)
|
||||
{
|
||||
serr() <<
|
||||
"SMT logic error during analysis:" <<
|
||||
endl <<
|
||||
boost::diagnostic_information(_exception);
|
||||
return false;
|
||||
}
|
||||
catch (Error const& _error)
|
||||
{
|
||||
if (_error.type() == Error::Type::DocstringParsingError)
|
||||
@ -735,23 +711,6 @@ bool CommandLineInterface::compile()
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
serr() << "Exception during compilation: " << boost::diagnostic_information(_exception) << endl;
|
||||
return false;
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
serr() << "Unknown exception during compilation" << (
|
||||
_e.what() ? ": " + string(_e.what()) : "."
|
||||
) << endl;
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
serr() << "Unknown exception during compilation." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1016,31 +975,10 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
||||
m_options.optimiserSettings()
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
if (!stack.parseAndAnalyze(src.first, src.second))
|
||||
successful = false;
|
||||
else
|
||||
stack.optimize();
|
||||
}
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
serr() << "Exception in assembler: " << boost::diagnostic_information(_exception) << endl;
|
||||
return false;
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
serr() <<
|
||||
"Unknown exception during compilation" <<
|
||||
(_e.what() ? ": " + string(_e.what()) : ".") <<
|
||||
endl;
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
serr() << "Unknown exception in assembler." << endl;
|
||||
return false;
|
||||
}
|
||||
if (!stack.parseAndAnalyze(src.first, src.second))
|
||||
successful = false;
|
||||
else
|
||||
stack.optimize();
|
||||
}
|
||||
|
||||
for (auto const& sourceAndStack: assemblyStacks)
|
||||
@ -1074,29 +1012,8 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
||||
|
||||
if (_language != yul::AssemblyStack::Language::Ewasm && _targetMachine == yul::AssemblyStack::Machine::Ewasm)
|
||||
{
|
||||
try
|
||||
{
|
||||
stack.translate(yul::AssemblyStack::Language::Ewasm);
|
||||
stack.optimize();
|
||||
}
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
serr() << "Exception in assembler: " << boost::diagnostic_information(_exception) << endl;
|
||||
return false;
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
serr() <<
|
||||
"Unknown exception during compilation" <<
|
||||
(_e.what() ? ": " + string(_e.what()) : ".") <<
|
||||
endl;
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
serr() << "Unknown exception in assembler." << endl;
|
||||
return false;
|
||||
}
|
||||
stack.translate(yul::AssemblyStack::Language::Ewasm);
|
||||
stack.optimize();
|
||||
|
||||
sout() << endl << "==========================" << endl;
|
||||
sout() << endl << "Translated source:" << endl;
|
||||
@ -1104,28 +1021,8 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
||||
}
|
||||
|
||||
yul::MachineAssemblyObject object;
|
||||
try
|
||||
{
|
||||
object = stack.assemble(_targetMachine);
|
||||
object.bytecode->link(m_options.linker.libraries);
|
||||
}
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
serr() << "Exception while assembling: " << boost::diagnostic_information(_exception) << endl;
|
||||
return false;
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
serr() << "Unknown exception during compilation" << (
|
||||
_e.what() ? ": " + string(_e.what()) : "."
|
||||
) << endl;
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
serr() << "Unknown exception while assembling." << endl;
|
||||
return false;
|
||||
}
|
||||
object = stack.assemble(_targetMachine);
|
||||
object.bytecode->link(m_options.linker.libraries);
|
||||
|
||||
sout() << endl << "Binary representation:" << endl;
|
||||
if (object.bytecode)
|
||||
|
@ -22,11 +22,16 @@
|
||||
*/
|
||||
|
||||
#include <solc/CommandLineInterface.h>
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
#include <boost/exception/all.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
|
||||
/*
|
||||
The equivalent of setlocale(LC_ALL, "C") is called before any user code is run.
|
||||
@ -53,24 +58,52 @@ static void setDefaultOrCLocale()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
setDefaultOrCLocale();
|
||||
solidity::frontend::CommandLineInterface cli(cin, cout, cerr);
|
||||
if (!cli.parseArguments(argc, argv))
|
||||
return 1;
|
||||
if (!cli.readInputFiles())
|
||||
return 1;
|
||||
if (!cli.processInput())
|
||||
return 1;
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
success = cli.actOnInput();
|
||||
setDefaultOrCLocale();
|
||||
solidity::frontend::CommandLineInterface cli(cin, cout, cerr);
|
||||
bool success =
|
||||
cli.parseArguments(argc, argv) &&
|
||||
cli.readInputFiles() &&
|
||||
cli.processInput() &&
|
||||
cli.actOnInput();
|
||||
|
||||
return success ? 0 : 1;
|
||||
}
|
||||
catch (smtutil::SMTLogicError const& _exception)
|
||||
{
|
||||
cerr << "SMT logic error:" << endl;
|
||||
cerr << boost::diagnostic_information(_exception);
|
||||
return 1;
|
||||
}
|
||||
catch (langutil::UnimplementedFeatureError const& _exception)
|
||||
{
|
||||
cerr << "Unimplemented feature:" << endl;
|
||||
cerr << boost::diagnostic_information(_exception);
|
||||
return 1;
|
||||
}
|
||||
catch (langutil::InternalCompilerError const& _exception)
|
||||
{
|
||||
cerr << "Internal compiler error:" << endl;
|
||||
cerr << boost::diagnostic_information(_exception);
|
||||
return 1;
|
||||
}
|
||||
catch (boost::exception const& _exception)
|
||||
{
|
||||
cerr << "Exception during output generation: " << boost::diagnostic_information(_exception) << endl;
|
||||
success = false;
|
||||
cerr << "Uncaught exception:" << endl;
|
||||
cerr << boost::diagnostic_information(_exception) << endl;
|
||||
return 1;
|
||||
}
|
||||
catch (std::exception const& _exception)
|
||||
{
|
||||
cerr << "Uncaught exception:" << endl;
|
||||
cerr << boost::diagnostic_information(_exception) << endl;
|
||||
return 1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cerr << "Uncaught exception" << endl;
|
||||
cerr << boost::current_exception_diagnostic_information() << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return success ? 0 : 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user