mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] main: Dealing with uncaught exceptions
This commit is contained in:
parent
c7051e1386
commit
4e90c598b3
@ -18,6 +18,8 @@
|
|||||||
#include <tools/yulPhaser/Exceptions.h>
|
#include <tools/yulPhaser/Exceptions.h>
|
||||||
#include <tools/yulPhaser/Phaser.h>
|
#include <tools/yulPhaser/Phaser.h>
|
||||||
|
|
||||||
|
#include <libsolutil/Exceptions.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@ -28,7 +30,51 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
catch (solidity::phaser::InvalidProgram const& exception)
|
catch (solidity::phaser::InvalidProgram const& exception)
|
||||||
{
|
{
|
||||||
|
// Error in the input data. One of the provided programs contains errors and could not be loaded.
|
||||||
|
// Handle it and exit.
|
||||||
|
|
||||||
|
std::cerr << std::endl;
|
||||||
std::cerr << "ERROR: " << exception.what() << std::endl;
|
std::cerr << "ERROR: " << exception.what() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
catch (solidity::util::Exception const& exception)
|
||||||
|
{
|
||||||
|
// Something's seriously wrong. Probably a bug in the program or a missing handler (which
|
||||||
|
// is really also a bug). The exception should have been handled gracefully by this point
|
||||||
|
// if it's something that can happen in normal usage. E.g. an error in the input or a
|
||||||
|
// failure of some part of the system that's outside of control of the application (disk,
|
||||||
|
// network, etc.). The bug should be reported and investigated so our job here is just to
|
||||||
|
// provide as much useful information about it as possible.
|
||||||
|
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "UNCAUGHT EXCEPTION!" << std::endl;
|
||||||
|
|
||||||
|
// We can print some useful diagnostic info for this particular exception type.
|
||||||
|
std::cerr << "Location: " << exception.lineInfo() << std::endl;
|
||||||
|
|
||||||
|
char const* const* function = boost::get_error_info<boost::throw_function>(exception);
|
||||||
|
if (function != nullptr)
|
||||||
|
std::cerr << "Function: " << *function << std::endl;
|
||||||
|
|
||||||
|
// Let it crash. The terminate() will print some more stuff useful for debugging like
|
||||||
|
// what() and the actual exception type.
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch (std::exception const&)
|
||||||
|
{
|
||||||
|
// Again, probably a bug but this time it's just plain std::exception so there's no point
|
||||||
|
// in doing anything special. terminate() will do an adequate job.
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "UNCAUGHT EXCEPTION!" << std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
// Some people don't believe these exist.
|
||||||
|
// I have no idea what this is and it's flying towards me so technically speaking it's an
|
||||||
|
// unidentified flying object.
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "UFO SPOTTED!" << std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user