Skip to content

Commit b45fbc0

Browse files
committed
[solc] Exit code 2 for exceptions.
1 parent 8830be9 commit b45fbc0

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Language Features:
44

55

66
Compiler Features:
7+
* Commandline Interface: Return exit code `2` on uncaught exceptions.
78
* Commandline Interface: Add `--no-cbor-metadata` that skips CBOR metadata from getting appended at the end of the bytecode.
89
* Standard JSON: Add a boolean field `settings.metadata.appendCBOR` that skips CBOR metadata from getting appended at the end of the bytecode.
910
* Yul Optimizer: Allow replacing the previously hard-coded cleanup sequence by specifying custom steps after a colon delimiter (``:``) in the sequence string.

solc/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,36 @@ int main(int argc, char** argv)
4444
{
4545
cerr << "SMT logic error:" << endl;
4646
cerr << boost::diagnostic_information(_exception);
47-
return 1;
47+
return 2;
4848
}
4949
catch (langutil::UnimplementedFeatureError const& _exception)
5050
{
5151
cerr << "Unimplemented feature:" << endl;
5252
cerr << boost::diagnostic_information(_exception);
53-
return 1;
53+
return 2;
5454
}
5555
catch (langutil::InternalCompilerError const& _exception)
5656
{
5757
cerr << "Internal compiler error:" << endl;
5858
cerr << boost::diagnostic_information(_exception);
59-
return 1;
59+
return 2;
6060
}
6161
catch (boost::exception const& _exception)
6262
{
6363
cerr << "Uncaught exception:" << endl;
6464
cerr << boost::diagnostic_information(_exception) << endl;
65-
return 1;
65+
return 2;
6666
}
6767
catch (std::exception const& _exception)
6868
{
6969
cerr << "Uncaught exception:" << endl;
7070
cerr << boost::diagnostic_information(_exception) << endl;
71-
return 1;
71+
return 2;
7272
}
7373
catch (...)
7474
{
7575
cerr << "Uncaught exception" << endl;
7676
cerr << boost::current_exception_diagnostic_information() << endl;
77-
return 1;
77+
return 2;
7878
}
7979
}

test/tools/isoltest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,22 +502,22 @@ int main(int argc, char const *argv[])
502502
catch (boost::program_options::error const& exception)
503503
{
504504
cerr << exception.what() << endl;
505-
return EXIT_FAILURE;
505+
return 2;
506506
}
507507
catch (std::runtime_error const& exception)
508508
{
509509
cerr << exception.what() << endl;
510-
return EXIT_FAILURE;
510+
return 2;
511511
}
512512
catch (solidity::test::ConfigException const& exception)
513513
{
514514
cerr << exception.what() << endl;
515-
return EXIT_FAILURE;
515+
return 2;
516516
}
517517
catch (...)
518518
{
519519
cerr << "Unhandled exception caught." << endl;
520520
cerr << boost::current_exception_diagnostic_information() << endl;
521-
return EXIT_FAILURE;
521+
return 2;
522522
}
523523
}

tools/solidityUpgrade/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ int main(int argc, char** argv)
8585
catch (boost::exception const& _exception)
8686
{
8787
cerr << "Exception while processing input: " << boost::diagnostic_information(_exception) << endl;
88+
return 2;
8889
}
8990
catch (...)
9091
{
9192
cerr << "Unknown exception while processing input: " << boost::current_exception_diagnostic_information() << endl;
93+
return 2;
9294
}
9395

9496
return 0;

tools/yulPhaser/main.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int main(int argc, char** argv)
3636

3737
std::cerr << std::endl;
3838
std::cerr << "ERROR: " << exception.what() << std::endl;
39-
return 1;
39+
return 2;
4040
}
4141
catch (solidity::phaser::BadInput const& exception)
4242
{
@@ -45,7 +45,7 @@ int main(int argc, char** argv)
4545

4646
std::cerr << std::endl;
4747
std::cerr << "ERROR: " << exception.what() << std::endl;
48-
return 1;
48+
return 2;
4949
}
5050
catch (solidity::util::Exception const& exception)
5151
{
@@ -65,26 +65,25 @@ int main(int argc, char** argv)
6565
char const* const* function = boost::get_error_info<boost::throw_function>(exception);
6666
if (function != nullptr)
6767
std::cerr << "Function: " << *function << std::endl;
68-
69-
// Let it crash. The terminate() will print some more stuff useful for debugging like
70-
// what() and the actual exception type.
71-
throw;
68+
std::cerr << "ERROR: " << exception.what() << std::endl;
69+
return 2;
7270
}
73-
catch (std::exception const&)
71+
catch (std::exception const& exception)
7472
{
7573
// Again, probably a bug but this time it's just plain std::exception so there's no point
7674
// in doing anything special. terminate() will do an adequate job.
7775
std::cerr << std::endl;
7876
std::cerr << "UNCAUGHT EXCEPTION!" << std::endl;
79-
throw;
77+
std::cerr << "ERROR: " << exception.what() << std::endl;
78+
return 2;
8079
}
8180
catch (...)
8281
{
8382
// Some people don't believe these exist.
84-
// I have no idea what this is and it's flying towards me so technically speaking it's an
83+
// I have no idea what this is, and it's flying towards me so technically speaking it's an
8584
// unidentified flying object.
8685
std::cerr << std::endl;
8786
std::cerr << "UFO SPOTTED!" << std::endl;
88-
throw;
87+
return 2;
8988
}
9089
}

0 commit comments

Comments
 (0)