当前位置: 首页>>代码示例>>C++>>正文


C++ exception类代码示例

本文整理汇总了C++中exception的典型用法代码示例。如果您正苦于以下问题:C++ exception类的具体用法?C++ exception怎么用?C++ exception使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了exception类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exceptionMessage

void Logging::exceptionMessage(const exception & e, const int err_no)
{
	cerr << "\nERROR: " << e.what() << std::endl << flush;
	ERROR_LOG << "Top level exception: " << e.what() << std::endl << flush;
	releaseFile();
	exit(err_no);
}
开发者ID:xstreck1,项目名称:TREMPPI,代码行数:7,代码来源:logging.cpp

示例2: rethrow_exception

 HPX_ATTRIBUTE_NORETURN void rethrow_exception(
     exception const& e, std::string const& func)
 {
     hpx::detail::throw_exception(
         hpx::exception(e.get_error(), e.what(), hpx::rethrow),
         func, hpx::get_error_file_name(e), hpx::get_error_line_number(e));
 }
开发者ID:7ev3n,项目名称:hpx,代码行数:7,代码来源:throw_exception.cpp

示例3: ToExceptionString

	wstring StringConverter::ToExceptionString (const exception &ex)
	{
		const SystemException *sysEx = dynamic_cast <const SystemException *> (&ex);
		if (sysEx)
			return ToWide (sysEx->what()) + L": " + sysEx->SystemText() + L": " + sysEx->GetSubject();

		if (ex.what() && !string (ex.what()).empty())
			return ToWide (GetTypeName (typeid (ex)) + ": " + ex.what());
		
		return ToWide (GetTypeName (typeid (ex)));
	}
开发者ID:josejamilena,项目名称:veracrypt,代码行数:11,代码来源:StringConverter.cpp

示例4: rethrows_if

 void rethrows_if(
     hpx::error_code& ec, exception const& e, std::string const& func)
 {
     if (&ec == &hpx::throws) {
         hpx::detail::rethrow_exception(e, func);
     } else {
         ec = make_error_code(e.get_error(), e.what(),
             func.c_str(), hpx::get_error_file_name(e).c_str(),
             hpx::get_error_line_number(e),
             (ec.category() == hpx::get_lightweight_hpx_category()) ?
                 hpx::lightweight_rethrow : hpx::rethrow);
     }
 }
开发者ID:7ev3n,项目名称:hpx,代码行数:13,代码来源:throw_exception.cpp

示例5: to_variant

   void to_variant( const exception& e, variant& v, uint32_t max_depth )
   {
      FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
      variant v_log;
      to_variant( e.get_log(), v_log, max_depth - 1 );
      mutable_variant_object tmp;
      tmp( "code", e.code() )
         ( "name", e.name() )
         ( "message", e.what() )
         ( "stack", v_log );
      v = variant( tmp, max_depth );

   }
开发者ID:FollowMyVote,项目名称:fc,代码行数:13,代码来源:exception.cpp

示例6:

void
error_log::log_unhandled(const char *func, const char *file, int line, const exception& x)
{
   cerr << "unhandled exception! " << endl;
   cerr << x.what() << endl;
   cerr << "caught in " << func << ", at line " << line << " of " << file << endl;
}
开发者ID:Lexus89,项目名称:wifi-arsenal,代码行数:7,代码来源:error_log.cpp

示例7: ap_set_content_type

int cxxsp_engine::display_exception(request_rec *r, const exception& ex) {
    ap_set_content_type(r, "text/html");
    if(!r->header_only) {
        ap_rputs(DOCTYPE_HTML_4_0T, r);
        ap_rputs("<html><head><title>C++ Server Pages: Exception</title></head>\n",r);
        ap_rputs("<body><h2>C++ Server Pages: Exception</h2>\n",r);
        ap_rprintf(r,"<p>An exception (%s) occured during generation/compilation "
                   "of the C++ Server Page.</p>\n",typeid(ex).name());
        ap_rputs("<p>Here is the detailed message:</p>\n",r);
        ap_rputs("<pre style=\"border: solid black 1px; padding: 3px\">",r);
        string msg = ex.what();
        for(string::size_type i = 0; i<msg.size(); ++i)
            switch(msg[i]) {
            case '<':
                msg.replace(i,1,"&lt;");
                break;
            case '>':
                msg.replace(i,1,"&gt;");
                break;
            case '&':
                msg.replace(i,1,"&amp;");
                break;
            default:
                break;
            }
        ap_rputs(msg.c_str(),r);
        ap_rputs("</pre>\n",r);
        ap_rputs("</body></html>",r);
    }
    return OK;
}
开发者ID:rzymek,项目名称:cxxsp,代码行数:31,代码来源:engine.cpp

示例8: onError

		void onError(const char* mod,exception& ex) {
			tprintf("error loading module %s: %s\n",mod,ex.what());
			cppsp::CompileException* ce = dynamic_cast<cppsp::CompileException*>(&ex);
			if (ce != NULL) {
				tprintf("compiler output:\n%s\n",ce->compilerOutput.c_str());
			}
		}
开发者ID:Safe3,项目名称:workspace,代码行数:7,代码来源:cppsp_standalone.C

示例9: push_exception

int push_exception(lua_State * L, exception const & e) {
    exception ** mem = static_cast<exception**>(lua_newuserdata(L, sizeof(exception*))); // NOLINT
    *mem = e.clone();
    luaL_getmetatable(L, exception_mt);
    lua_setmetatable(L, -2);
    return 1;
}
开发者ID:dumganhar,项目名称:lean-osx,代码行数:7,代码来源:exception.cpp

示例10: rethrow

 void NO_RETURN exception_factory::rethrow( const exception& e )const
 {
    auto itr = _registered_exceptions.find( e.code() );
    if( itr != _registered_exceptions.end() )
       itr->second->rethrow( e );
    throw e;
 }
开发者ID:FollowMyVote,项目名称:fc,代码行数:7,代码来源:exception.cpp

示例11: DisplayError

void DisplayError(const exception& inErr)
{
	if (typeid(inErr) == typeid(HError))
		cerr << "Exception: " << static_cast<const HError&>(inErr).GetErrorString() << endl;
	else
		cerr << "Exception: " <<  inErr.what() << endl;
}
开发者ID:BackupTheBerlios,项目名称:mrs-svn,代码行数:7,代码来源:HError.cpp

示例12: failure

 void SessionImpl::failure( const shared_ptr< Session > session, const int status, const exception& error ) const
 {
     const auto handler = ( m_resource not_eq nullptr and m_resource->m_pimpl->m_error_handler not_eq nullptr ) ? m_resource->m_pimpl->m_error_handler : m_error_handler;
     
     if ( handler not_eq nullptr )
     {
         handler( status, error, session );
     }
     else
     {
         log( Logger::Level::ERROR, String::format( "Error %i, %s", status, error.what( ) ) );
         
         string body = error.what( );
         session->close( status, body, { { "Content-Type", "text/plain" }, { "Content-Length", ::to_string( body.length( ) ) } } );
     }
 }
开发者ID:gitforks,项目名称:restbed,代码行数:16,代码来源:session_impl.cpp

示例13: chainException

void exception::chainException(const exception& other)
{
	exception* e = other.clone();

	delete m_other;
	m_other = e;
}
开发者ID:8ackl0,项目名称:vmime,代码行数:7,代码来源:exception.cpp

示例14: default_show_function

void exception::default_show_function (const exception& err)
// Send a formatted report to standard error and to the Debug stream.
 {
 wstring s= err.What();
 std::wcerr << s;  // sic, should be werr.
 const wchar_t* buffer= s.c_str();
 ratwin::util::OutputDebugString (buffer);
 }
开发者ID:jdlugosz,项目名称:repertoire,代码行数:8,代码来源:exception.cpp

示例15: throw

 BINLINE BException::BException(const exception& ex) throw() {
   const BException* bex = dynamic_cast<const BException*>(&ex);
   if (bex) {
     data = bex->data;
   }
   else {
     init(BExceptionC::INTERNAL, L"", L"", ex.what());
   }
 }
开发者ID:digideskio,项目名称:byps,代码行数:9,代码来源:BException.hpp


注:本文中的exception类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。