Skip to content

Commit 2244351

Browse files
Move catch to the end of main
1 parent cd496e7 commit 2244351

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

more_bin.cpp

+7-14
Original file line numberDiff line numberDiff line change
@@ -289,26 +289,15 @@ int main(int argc, char** argv)
289289
bool byteswap = (vm.count("byteswap") > 0);
290290
bool quiet = (vm.count("quiet") > 0);
291291
string dataType = DEFAULT_TYPE;
292-
try {
293-
if (vm.count("type"))
294-
dataType = vm["type"].as<string>();
295-
} catch (boost::bad_any_cast &e) {
296-
cerr << "While parsing command line options (type): " << e.what() << endl;
297-
return -1;
298-
}
292+
if (vm.count("type"))
293+
dataType = vm["type"].as<string>();
299294
bool showLines = (vm.count("lines") > 0);
300295

301296
// hidden options
302297
vector<string> files;
303298
if (vm.count("filename"))
304299
{
305-
try {
306-
files = vm["filename"].as<vector<string> >();
307-
} catch (boost::bad_any_cast &e) {
308-
cerr << "While parsing command line options (filename): " << e.what()
309-
<< endl;
310-
return -1;
311-
}
300+
files = vm["filename"].as<vector<string> >();
312301
}
313302
else
314303
{
@@ -352,6 +341,10 @@ int main(int argc, char** argv)
352341
} catch(std::runtime_error &e) {
353342
cerr << "RUNTIME ERROR:" << e.what() << endl;
354343
return -1;
344+
} catch (boost::bad_any_cast &e) {
345+
cerr << "While parsing command line options: " << e.what()
346+
<< endl;
347+
return -1;
355348
}
356349

357350
return 0;

0 commit comments

Comments
 (0)