void BaseTest::safe_run( int start_from ) { CV_TRACE_FUNCTION(); read_params( ts->get_file_storage() ); ts->update_context( 0, -1, true ); ts->update_context( this, -1, true ); if( !::testing::GTEST_FLAG(catch_exceptions) ) run( start_from ); else { try { #if !defined _WIN32 int _code = setjmp( tsJmpMark ); if( !_code ) run( start_from ); else throw TS::FailureCode(_code); #else run( start_from ); #endif } catch (const cv::Exception& exc) { const char* errorStr = cvErrorStr(exc.code); char buf[1 << 16]; const char* delim = exc.err.find('\n') == cv::String::npos ? "" : "\n"; sprintf( buf, "OpenCV Error:\n\t%s (%s%s) in %s, file %s, line %d", errorStr, delim, exc.err.c_str(), exc.func.size() > 0 ? exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line ); ts->printf(TS::LOG, "%s\n", buf); ts->set_failed_test_info( TS::FAIL_ERROR_IN_CALLED_FUNC ); } catch (const TS::FailureCode& fc) { std::string errorStr = TS::str_from_code(fc); ts->printf(TS::LOG, "General failure:\n\t%s (%d)\n", errorStr.c_str(), fc); ts->set_failed_test_info( fc ); } catch (...) { ts->printf(TS::LOG, "Unknown failure\n"); ts->set_failed_test_info( TS::FAIL_EXCEPTION ); } } ts->set_gtest_status(); }
PHP_OPENCV_API void php_opencv_throw_exception(TSRMLS_D) { char * error_message; int status = cvGetErrStatus(); if (status >= 0) { return; } error_message = estrdup(cvErrorStr(status)); zend_throw_exception(opencv_ce_cvexception, error_message, status TSRMLS_CC); efree(error_message); return; }
void error(const char *error_string, const char *file, const int line, const char *func) { int code = CV_GpuApiCallError; if (std::uncaught_exception()) { const char *errorStr = cvErrorStr(code); const char *function = func ? func : "unknown function"; std::cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line; std::cerr.flush(); } else cv::error( cv::Exception(code, error_string, func, file, line) ); }
void error( const Exception& exc ) { if (customErrorCallback != 0) customErrorCallback(exc.code, exc.func.c_str(), exc.err.c_str(), exc.file.c_str(), exc.line, customErrorCallbackData); else { const char* errorStr = cvErrorStr(exc.code); char buf[1 << 16]; sprintf( buf, "OpenCV Error: %s (%s) in %s, file %s, line %d", errorStr, exc.err.c_str(), exc.func.size() > 0 ? exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line ); fprintf( stderr, "%s\n", buf ); fflush( stderr ); } if(breakOnError) { static volatile int* p = 0; *p = 0; } throw exc; }
static int tsErrorCallback( int status, const char* func_name, const char* err_msg, const char* file_name, int line, TS* ts ) { ts->printf(TS::LOG, "OpenCV Error:\n\t%s (%s) in %s, file %s, line %d\n", cvErrorStr(status), err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line); return 0; }
const char* cveErrorStr(int status) { return cvErrorStr(status); }
static int tsErrorCallback( int status, const char* func_name, const char* err_msg, const char* file_name, int line, TS* ts ) { const char* delim = std::string(err_msg).find('\n') == std::string::npos ? "" : "\n"; ts->printf(TS::LOG, "OpenCV Error:\n\t%s (%s%s) in %s, file %s, line %d\n", cvErrorStr(status), delim, err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line); return 0; }