File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 44#include < stdexcept>
55using namespace std ;
66
7- int throw_if_zero (int i) noexcept {
7+ void throw_if_zero (int i) noexcept {
88 if (!i) {
99 throw runtime_error (" found a zero" );
1010 }
1111 println (" throw_if_zero(): {}" , i);
1212}
1313
1414int main () {
15- cout << " Entering main()\n " ;
15+ println ( " Entering main()" ) ;
1616 try {
1717 throw_if_zero (1 );
1818 throw_if_zero (0 );
1919 }
20- catch (... ) {
21- println (" Caught an exception! " );
20+ catch (exception& e ) {
21+ println (" Caught an exception: {} " , e. what () );
2222 }
23- println (" Leaving main()\n " );
23+ println (" Leaving main()" );
2424}
Original file line number Diff line number Diff line change 33import std;
44using namespace std ;
55
6- int throw_if_zero (int i) noexcept {
6+ void throw_if_zero (int i) noexcept {
77 if (!i) {
88 throw runtime_error (" found a zero" );
99 }
1010 println (" throw_if_zero(): {}" , i);
1111}
1212
1313int main () {
14- cout << " Entering main()\n " ;
14+ println ( " Entering main()" ) ;
1515 try {
1616 throw_if_zero (1 );
1717 throw_if_zero (0 );
1818 }
19- catch (... ) {
20- println (" Caught an exception! " );
19+ catch (exception& e ) {
20+ println (" Caught an exception: {} " , e. what () );
2121 }
22- println (" Leaving main()\n " );
22+ println (" Leaving main()" );
2323}
You can’t perform that action at this time.
0 commit comments