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


C++ Exception::toString方法代码示例

本文整理汇总了C++中Exception::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ Exception::toString方法的具体用法?C++ Exception::toString怎么用?C++ Exception::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exception的用法示例。


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

示例1: ParserException

 ParserException(const Exception& ex,
     int aScriptLine, int aScriptPos,
     const char* aFile, int aLine)
     : Exception(aFile, aLine),
     scriptLine(aScriptLine),
     scriptPos(aScriptPos)
 {
     description = ex.toString();
 }
开发者ID:Totktonada,项目名称:management-game-bot,代码行数:9,代码来源:ParserException.hpp

示例2: l

	extern "C" void segfaulth(int sig,siginfo_t *siginfo, void *secret)
	{

		///c++ abi: nothing to play with
		/*
  ucontext_t *uc=(ucontext_t*)secret;
#ifdef __powerpc__
  signal.setFaultPosition((void *)uc->uc_mcontext.regs->nip);
#else
# ifdef __mips__
  signal.setFaultPosition((void *)( (int) ( uc->uc_mcontext.pc & (0xffffffff) ) ));
# else
  signal.setFaultPosition((void *)uc->uc_mcontext.gregs[REG_EIP]);
# endif
#endif
		 */
		//cerr <<  signal.getStackTrace();
		//cerr << signal.what();

		const char* detail_=fault_detail(sig,siginfo);
		char detail[1024];
		void *faultAddr=NULL;

		SegfaultBuffer emergencyBuffer;
		SegfaultBuffer *oldBuffer=NULL;
		bool stuckCandidate=false;

		if ( siginfo ) faultAddr=siginfo->si_addr;

		snprintf(detail,1024,"Signal (%d) : %s [%p]",sig,detail_,faultAddr);

		fprintf(stderr,"IN RAII SEGFAULT HANDLER, %s\n",detail);fflush(stderr);
               if(1){ //code à activer si demangle et throw merdouillent après segfault
                Exception e;
                std::cerr <<  e.toString() << "\n";
                std::cerr << e.getMessage() << "\n";
                e.poorManPrintStackTrace(false);
                }

		if ( !segfaultBuffer || sig == SIGUSR2 ) {
		        
			fprintf(stderr,
			        sig == SIGUSR2
			        ? "dumping stack\n"
			        : "segfaultBuffer is NULL (not in raii request)!\n");fflush(stderr);
			oldBuffer=segfaultBuffer;
			segfaultBuffer=&emergencyBuffer;
			stuckCandidate=true;
		}
 
		{ // segfaultBuffer is not null, in raii request
			switch (sig)
			{
				case SIGILL:
					segfaultBuffer->exception=new IllegalInstruction(detail);
					break;
				case SIGFPE:
					segfaultBuffer->exception=new FloatingPointException(detail);
					break;
				case SIGSEGV:
					segfaultBuffer->exception=new SegmentationFault(detail);
					break;
				case SIGBUS:
					segfaultBuffer->exception=new BusError(detail);
					break;
				case SIGABRT:
					segfaultBuffer->exception=new Abort(detail);
					break;
				case SIGUSR2:
					segfaultBuffer->exception=new DumpStack(detail);
				default:
					segfaultBuffer->exception=new Signal(detail);
			}
			if ( !segfaultBuffer->exception )
				fprintf(stderr,"UNABLE TO INSTANCIATE EXCEPTION\n");
			else {
				fprintf(stderr,"EXCEPTION INSTANCIATED, STACKTRACE SIZE IS %d\n",segfaultBuffer->exception->depth);
				fflush(stderr);


				segfaultBuffer->exception->depth=backtrace(segfaultBuffer->exception->stackTrace,1024);
				segfaultBuffer->exception->start=2;
				//int i;
/*
				//0 -> segfaulth
				//1 -> __restore_rt
				for ( i=2 ; i < depth ; i++ ) {
					segfaultBuffer->exception->stackTrace_.push_back(p[i]);
				}
				*/

			}
			fflush(stderr);

			segfaultBuffer->signal=sig;
			if ( stuckCandidate ) {
				segfaultBuffer=oldBuffer; //last state
				{
					static Mutex serialize_output;
					Lock l(serialize_output);
//.........这里部分代码省略.........
开发者ID:ploki,项目名称:libapache2-mod-raii,代码行数:101,代码来源:segfault.C


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