Skip to content

Commit 0bde00a

Browse files
Leonid BeynensonLeonid Beynenson
authored andcommitted
Changed CommandLineParser to make it less verbose
when it is unrequired.
1 parent 858f437 commit 0bde00a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

modules/core/src/command_line_parser.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ static void from_str(const string& str, int type, void* dst)
7272
else if( type == Param::STRING )
7373
ss >> *(string*)dst;
7474
else
75-
CV_Error(CV_StsBadArg, "unknown/unsupported parameter type");
75+
throw cv::Exception(CV_StsBadArg, "unknown/unsupported parameter type", __func__, __FILE__, __LINE__);
7676

7777
if (ss.fail())
7878
{
7979
string err_msg = "can not convert: [" + str +
8080
+ "] to [" + get_type_name(type) + "]";
8181

82-
CV_Error(CV_StsBadArg, err_msg);
82+
throw cv::Exception(CV_StsBadArg, err_msg, __func__, __FILE__, __LINE__);
8383
}
8484
}
8585

@@ -417,14 +417,15 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
417417
{
418418
if (begin == true)
419419
{
420-
CV_Error(CV_StsParseError,
420+
throw cv::Exception(CV_StsParseError,
421421
string("error in split_range_string(")
422422
+ str
423423
+ string(", ")
424424
+ string(1, fs)
425425
+ string(", ")
426426
+ string(1, ss)
427-
+ string(")")
427+
+ string(")"),
428+
__func__, __FILE__, __LINE__
428429
);
429430
}
430431
begin = true;
@@ -436,14 +437,15 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
436437
{
437438
if (begin == false)
438439
{
439-
CV_Error(CV_StsParseError,
440+
throw cv::Exception(CV_StsParseError,
440441
string("error in split_range_string(")
441442
+ str
442443
+ string(", ")
443444
+ string(1, fs)
444445
+ string(", ")
445446
+ string(1, ss)
446-
+ string(")")
447+
+ string(")"),
448+
__func__, __FILE__, __LINE__
447449
);
448450
}
449451
begin = false;
@@ -459,15 +461,16 @@ vector<string> CommandLineParser::Impl::split_range_string(const string& _str, c
459461

460462
if (begin == true)
461463
{
462-
CV_Error(CV_StsParseError,
464+
throw cv::Exception(CV_StsParseError,
463465
string("error in split_range_string(")
464466
+ str
465467
+ string(", ")
466468
+ string(1, fs)
467469
+ string(", ")
468470
+ string(1, ss)
469-
+ string(")")
470-
);
471+
+ string(")"),
472+
__func__, __FILE__, __LINE__
473+
);
471474
}
472475

473476
return vec;

0 commit comments

Comments
 (0)