File tree 2 files changed +10
-10
lines changed
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 4
4
#include < stdexcept>
5
5
using namespace std ;
6
6
7
- int throw_if_zero (int i) noexcept {
7
+ void throw_if_zero (int i) noexcept {
8
8
if (!i) {
9
9
throw runtime_error (" found a zero" );
10
10
}
11
11
println (" throw_if_zero(): {}" , i);
12
12
}
13
13
14
14
int main () {
15
- cout << " Entering main()\n " ;
15
+ println ( " Entering main()" ) ;
16
16
try {
17
17
throw_if_zero (1 );
18
18
throw_if_zero (0 );
19
19
}
20
- catch (... ) {
21
- println (" Caught an exception! " );
20
+ catch (exception & e ) {
21
+ println (" Caught an exception: {} " , e. what () );
22
22
}
23
- println (" Leaving main()\n " );
23
+ println (" Leaving main()" );
24
24
}
Original file line number Diff line number Diff line change 3
3
import std;
4
4
using namespace std ;
5
5
6
- int throw_if_zero (int i) noexcept {
6
+ void throw_if_zero (int i) noexcept {
7
7
if (!i) {
8
8
throw runtime_error (" found a zero" );
9
9
}
10
10
println (" throw_if_zero(): {}" , i);
11
11
}
12
12
13
13
int main () {
14
- cout << " Entering main()\n " ;
14
+ println ( " Entering main()" ) ;
15
15
try {
16
16
throw_if_zero (1 );
17
17
throw_if_zero (0 );
18
18
}
19
- catch (... ) {
20
- println (" Caught an exception! " );
19
+ catch (exception & e ) {
20
+ println (" Caught an exception: {} " , e. what () );
21
21
}
22
- println (" Leaving main()\n " );
22
+ println (" Leaving main()" );
23
23
}
You can’t perform that action at this time.
0 commit comments