mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 01:13:28 +08:00
core: drop cv::errorNoReturn()
replaced to cv::error()
This commit is contained in:
parent
cd2b188c9a
commit
4e83f4c579
@ -144,7 +144,7 @@ It is possible to alternate error processing by using #redirectError().
|
|||||||
@param exc the exception raisen.
|
@param exc the exception raisen.
|
||||||
@deprecated drop this version
|
@deprecated drop this version
|
||||||
*/
|
*/
|
||||||
CV_EXPORTS void error( const Exception& exc );
|
CV_EXPORTS CV_NORETURN void error(const Exception& exc);
|
||||||
|
|
||||||
enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
|
enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
|
||||||
SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted
|
SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted
|
||||||
|
@ -373,32 +373,7 @@ It is possible to alternate error processing by using redirectError().
|
|||||||
@param _line - line number in the source file where the error has occurred
|
@param _line - line number in the source file where the error has occurred
|
||||||
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
|
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
|
||||||
*/
|
*/
|
||||||
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# if defined __clang__ || defined __APPLE__
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** same as cv::error, but does not return */
|
|
||||||
CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line)
|
|
||||||
{
|
|
||||||
error(_code, _err, _func, _file, _line);
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# if !defined __clang__ && !defined __APPLE__
|
|
||||||
// this suppresses this warning: "noreturn" function does return [enabled by default]
|
|
||||||
__builtin_trap();
|
|
||||||
// or use infinite loop: for (;;) {}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# if defined __clang__ || defined __APPLE__
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
#define CV_Func __func__
|
#define CV_Func __func__
|
||||||
@ -446,25 +421,19 @@ for example:
|
|||||||
|
|
||||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||||
|
|
||||||
|
#endif // CV_STATIC_ANALYSIS
|
||||||
|
|
||||||
//! @cond IGNORED
|
//! @cond IGNORED
|
||||||
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
#if !defined(__OPENCV_BUILD) // TODO: backward compatibility only
|
||||||
#define CV__ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
#ifndef CV_ErrorNoReturn
|
||||||
#ifdef __OPENCV_BUILD
|
#define CV_ErrorNoReturn CV_Error
|
||||||
#undef CV_Error
|
#endif
|
||||||
#define CV_Error CV__ErrorNoReturn
|
#ifndef CV_ErrorNoReturn_
|
||||||
#undef CV_Error_
|
#define CV_ErrorNoReturn_ CV_Error_
|
||||||
#define CV_Error_ CV__ErrorNoReturn_
|
#endif
|
||||||
#undef CV_Assert_1
|
|
||||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
|
||||||
#else
|
|
||||||
// backward compatibility
|
|
||||||
#define CV_ErrorNoReturn CV__ErrorNoReturn
|
|
||||||
#define CV_ErrorNoReturn_ CV__ErrorNoReturn_
|
|
||||||
#endif
|
#endif
|
||||||
//! @endcond
|
//! @endcond
|
||||||
|
|
||||||
#endif // CV_STATIC_ANALYSIS
|
|
||||||
|
|
||||||
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
|
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
|
||||||
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
|
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
|
||||||
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
||||||
|
@ -67,7 +67,7 @@ void check_failed_auto_(const T& v1, const T& v2, const CheckContext& ctx)
|
|||||||
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
|
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
|
||||||
}
|
}
|
||||||
ss << " '" << ctx.p2_str << "' is " << v2;
|
ss << " '" << ctx.p2_str << "' is " << v2;
|
||||||
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
||||||
}
|
}
|
||||||
void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
|
void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
|
||||||
{
|
{
|
||||||
@ -79,7 +79,7 @@ void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
|
|||||||
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
|
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
|
||||||
}
|
}
|
||||||
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << depthToString(v2) << ")";
|
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << depthToString(v2) << ")";
|
||||||
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
||||||
}
|
}
|
||||||
void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
|
void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
|
|||||||
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
|
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
|
||||||
}
|
}
|
||||||
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << typeToString(v2) << ")";
|
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << typeToString(v2) << ")";
|
||||||
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
||||||
}
|
}
|
||||||
void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx)
|
void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx)
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ void check_failed_auto_(const T& v, const CheckContext& ctx)
|
|||||||
<< " '" << ctx.p2_str << "'" << std::endl
|
<< " '" << ctx.p2_str << "'" << std::endl
|
||||||
<< "where" << std::endl
|
<< "where" << std::endl
|
||||||
<< " '" << ctx.p1_str << "' is " << v;
|
<< " '" << ctx.p1_str << "' is " << v;
|
||||||
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
||||||
}
|
}
|
||||||
void check_failed_MatDepth(const int v, const CheckContext& ctx)
|
void check_failed_MatDepth(const int v, const CheckContext& ctx)
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ void check_failed_MatDepth(const int v, const CheckContext& ctx)
|
|||||||
<< " '" << ctx.p2_str << "'" << std::endl
|
<< " '" << ctx.p2_str << "'" << std::endl
|
||||||
<< "where" << std::endl
|
<< "where" << std::endl
|
||||||
<< " '" << ctx.p1_str << "' is " << v << " (" << depthToString(v) << ")";
|
<< " '" << ctx.p1_str << "' is " << v << " (" << depthToString(v) << ")";
|
||||||
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
||||||
}
|
}
|
||||||
void check_failed_MatType(const int v, const CheckContext& ctx)
|
void check_failed_MatType(const int v, const CheckContext& ctx)
|
||||||
{
|
{
|
||||||
@ -137,7 +137,7 @@ void check_failed_MatType(const int v, const CheckContext& ctx)
|
|||||||
<< " '" << ctx.p2_str << "'" << std::endl
|
<< " '" << ctx.p2_str << "'" << std::endl
|
||||||
<< "where" << std::endl
|
<< "where" << std::endl
|
||||||
<< " '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")";
|
<< " '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")";
|
||||||
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
|
||||||
}
|
}
|
||||||
void check_failed_MatChannels(const int v, const CheckContext& ctx)
|
void check_failed_MatChannels(const int v, const CheckContext& ctx)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ inline static bool checkError(const char* file, const int line, const char* func
|
|||||||
default:
|
default:
|
||||||
msg = "Unknown error";
|
msg = "Unknown error";
|
||||||
};
|
};
|
||||||
cv::errorNoReturn(Error::OpenGlApiCallError, func, msg, file, line);
|
cv::error(Error::OpenGlApiCallError, func, msg, file, line);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ void icvParseError( CvFileStorage* fs, const char* func_name,
|
|||||||
const char* err_msg, const char* source_file, int source_line )
|
const char* err_msg, const char* source_file, int source_line )
|
||||||
{
|
{
|
||||||
cv::String msg = cv::format("%s(%d): %s", fs->filename, fs->lineno, err_msg);
|
cv::String msg = cv::format("%s(%d): %s", fs->filename, fs->lineno, err_msg);
|
||||||
cv::errorNoReturn(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
|
cv::error(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
|
||||||
}
|
}
|
||||||
|
|
||||||
void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )
|
void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )
|
||||||
|
@ -970,6 +970,13 @@ static void cv_terminate_handler() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# if defined __clang__ || defined __APPLE__
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void error( const Exception& exc )
|
void error( const Exception& exc )
|
||||||
{
|
{
|
||||||
#ifdef CV_ERROR_SET_TERMINATE_HANDLER
|
#ifdef CV_ERROR_SET_TERMINATE_HANDLER
|
||||||
@ -1000,13 +1007,33 @@ void error( const Exception& exc )
|
|||||||
}
|
}
|
||||||
|
|
||||||
CV_THROW(exc);
|
CV_THROW(exc);
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# if !defined __clang__ && !defined __APPLE__
|
||||||
|
// this suppresses this warning: "noreturn" function does return [enabled by default]
|
||||||
|
__builtin_trap();
|
||||||
|
// or use infinite loop: for (;;) {}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
|
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
|
||||||
{
|
{
|
||||||
error(cv::Exception(_code, _err, _func, _file, _line));
|
error(cv::Exception(_code, _err, _func, _file, _line));
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# if !defined __clang__ && !defined __APPLE__
|
||||||
|
// this suppresses this warning: "noreturn" function does return [enabled by default]
|
||||||
|
__builtin_trap();
|
||||||
|
// or use infinite loop: for (;;) {}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# if defined __clang__ || defined __APPLE__
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ErrorCallback
|
ErrorCallback
|
||||||
redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)
|
redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)
|
||||||
|
@ -274,11 +274,7 @@ inline int DictValue::size() const
|
|||||||
case Param::REAL:
|
case Param::REAL:
|
||||||
return (int)pd->size();
|
return (int)pd->size();
|
||||||
}
|
}
|
||||||
#ifdef __OPENCV_BUILD
|
|
||||||
CV_Error(Error::StsInternal, "");
|
CV_Error(Error::StsInternal, "");
|
||||||
#else
|
|
||||||
CV_ErrorNoReturn(Error::StsInternal, "");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)
|
inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)
|
||||||
|
@ -603,7 +603,7 @@ void cv::setWindowTitle(const String&, const String&)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CV_NO_GUI_ERROR(funcname) \
|
#define CV_NO_GUI_ERROR(funcname) \
|
||||||
cv::errorNoReturn(cv::Error::StsError, \
|
cv::error(cv::Error::StsError, \
|
||||||
"The function is not implemented. " \
|
"The function is not implemented. " \
|
||||||
"Rebuild the library with Windows, GTK+ 2.x or Carbon support. "\
|
"Rebuild the library with Windows, GTK+ 2.x or Carbon support. "\
|
||||||
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script", \
|
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script", \
|
||||||
|
Loading…
Reference in New Issue
Block a user