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


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

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


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

示例1: catchException

bool Debugger::catchException(Thread* thread, Frame* frame, const Exception& ex)
{
	Frame* myframe = getFrame();
	BEER_STACK_CHECK();

	cout << std::endl << "--------- EXCEPTION ---------" << std::endl;
	printLastOutput();
	printFrame(thread, frame);

	if(ex.getName().compare(BEER_WIDEN("MethodNotFoundException")) == 0) // TODO: better
	{
		cout << std::endl;

		StackRef<Object> receiver(myframe, myframe->stackPush(
			frame->stackTop()
		));

		NULL_ASSERT(*receiver); // TODO

		StackRef<Class> klass(myframe, myframe->stackPush());
		getType(receiver, klass);

		printClassMethods(klass);
		
		myframe->stackMoveTop(-2);  //pop receiver & klass
	}
	
	cout << "\n[" << ex.getName() << "]\n" << ex.getMessage() << " @" << ex.getFilename() << ":" << ex.getFileline() << std::endl;

	return false; // TODO
}
开发者ID:maca89,项目名称:Beer,代码行数:31,代码来源:Debugger.cpp

示例2:

/*	Purpose: copy constructor; designed to copy one exception to another via reference
                 
    Inputs: takes an existing exception by reference, applies the input exception's message to the target exception

    Outputs: no return values
*/
Exception::Exception(const Exception& aException) {
	cout << "Copy Constructor..." << endl;
	setMessage(aException.getMessage());
	//m_msg = new char[MAX_BUF];
	//int b=strlen(aException.getMessage())+1;
	//memcpy(m_msg,aException.getMessage(),b);
}
开发者ID:dfbarth,项目名称:cst211,代码行数:13,代码来源:1_array.cpp

示例3: FatalException

void FatalException(Exception &e, std::string const &location) {
    DataError *pDataError = dynamic_cast<DataError*> (&e);
    CSPLOG(ERROR, APP) << "CSPSim: caught exception in " << location << ": " << e.getMessage();
    std::cerr << "\n";
    e.details();
    std::cerr << "\n";
    if (pDataError) {
        std::cerr
                << "Please check that the data paths in CSPSim.ini are set to reasonable\n"
                << "values (CSPSim.ini is usually found in CSPSim/Data).  If you appear\n"
                << "to be missing a necessary data file, please check the CSP download\n"
                << "page for the latest data releases or ask for assistance on the CSP\n"
                << "forums:\n"
                << "                http://csp.sourceforge.net/forum\n";
    }
    else {
        std::cerr
                << "CSPSim: caught an exception.  Please report this along with\n"
                << "as much information as possible about what was happening at \n"
                << "the time of the error to the CSP forum at\n"
                << "              http://csp.sourceforge.net/forum\n";
    }
    std::cerr << std::endl;
    ::exit(1);
}
开发者ID:nsmoooose,项目名称:csp,代码行数:25,代码来源:Exception.cpp

示例4: Log

void Logger::Log(LogLevelType level, const char *type, const Exception &e,
                 const char *file /* = NULL */, int line /* = 0 */) {
  if (!IsEnabled()) return;
  auto msg = type + e.getMessage();
  if (file && file[0]) {
    msg += folly::sformat(" in {} on line {}", file, line);
  }
  LogImpl(level, msg, nullptr);
}
开发者ID:DerPapst,项目名称:hhvm,代码行数:9,代码来源:logger.cpp

示例5:

 Exception::Exception (const Exception& ex)
 {
     location = ex.getLocation();
     this->message = ex.getMessage();
     if (!ex.getModuleName().empty())
         this->previous = ex.getModuleName();
     else
     if (!ex.module().empty())
         this->previous = ex.module() + "::";
 }
开发者ID:BackupTheBerlios,项目名称:xicorr-svn,代码行数:10,代码来源:exception.cpp

示例6: createMessageFormatException

MessageFormatException CMSExceptionSupport::createMessageFormatException( const Exception& cause ) {

    std::string msg = cause.getMessage();

    if( msg.length() == 0 ) {
        msg = typeid( &cause ).name();
    }

    MessageFormatException exception( msg, cause.clone() );

    return exception;
}
开发者ID:WilliamDrewAeroNomos,项目名称:muthur,代码行数:12,代码来源:CMSExceptionSupport.cpp

示例7: log

void Logger::log(LogLevelType level, const char *type, const Exception &e,
                 const char *file /* = NULL */, int line /* = 0 */) {
  if (!IsEnabled()) return;

  std::string msg = type;
  msg += e.getMessage();
  if (file && file[0]) {
    std::ostringstream os;
    os << " in " << file << " on line " << line;
    msg += os.str();
  }
  Log(level, msg, nullptr);
}
开发者ID:davideme,项目名称:hiphop-php,代码行数:13,代码来源:logger.cpp

示例8: testClone

void ExceptionTest::testClone() {

    const char* text = "This is a test";
    Exception ex( __FILE__, __LINE__, text );
    CPPUNIT_ASSERT( strcmp( ex.getMessage().c_str(), text ) == 0 );
    CPPUNIT_ASSERT( ex.getCause() == NULL );

    Exception* cloned = ex.clone();

    CPPUNIT_ASSERT( strcmp( cloned->getMessage().c_str(), text ) == 0 );
    CPPUNIT_ASSERT( cloned->getCause() == NULL );

    delete cloned;
}
开发者ID:WilliamDrewAeroNomos,项目名称:muthur,代码行数:14,代码来源:ExceptionTest.cpp

示例9: callUserErrorHandler

bool ExecutionContext::callUserErrorHandler(const Exception &e, int64 errnum,
                                            bool swallowExceptions) {
  int errline = 0;
  String errfile;
  Array backtrace;
  const ExtendedException *ee = dynamic_cast<const ExtendedException*>(&e);
  if (ee) {
    ArrayPtr arr = ee->getBackTrace();
    if (arr) {
      backtrace = *arr;
      Array top = backtrace.rvalAt(0);
      if (!top.isNull()) {
        errfile = top.rvalAt("file");
        errline = top.rvalAt("line").toInt64();
      }
    }
  }
  if (backtrace.isNull()) {
    backtrace = stackTraceToBackTrace(e.getStackTrace());
  }

  bool retval = false;
  RequestData::Data *data = s_request_data->data;
  if (!data->systemExceptionHandlers.empty()) {
    // Avoid calling the user error handler recursively
    if (!data->insideUserHandler) {
      data->insideUserHandler = true;
      try {
        if (!same(f_call_user_func_array
                  (data->systemExceptionHandlers.back(),
                   CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
                                  errline, "", backtrace)),
                  false)) {
          retval = true;
        }
      } catch (...) {
        data->insideUserHandler = false;
        if (!swallowExceptions) throw;
      }
      data->insideUserHandler = false;
    }
  }

  return retval;
}
开发者ID:sumitk,项目名称:hiphop-php,代码行数:45,代码来源:execution_context.cpp

示例10: callUserErrorHandler

bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum,
                                                bool swallowExceptions) {
  switch (getErrorState()) {
  case ExecutingUserHandler:
  case ErrorRaisedByUserHandler:
    return false;
  default:
    break;
  }
  if (!m_userErrorHandlers.empty() &&
      (m_userErrorHandlers.back().second & errnum) != 0) {
    int errline = 0;
    String errfile;
    Array backtrace;
    const ExtendedException *ee = dynamic_cast<const ExtendedException*>(&e);
    if (ee) {
      ArrayPtr arr = ee->getBackTrace();
      if (arr) {
        backtrace = *arr;
        Array top = backtrace.rvalAt(0);
        if (!top.isNull()) {
          errfile = top.rvalAt("file");
          errline = top.rvalAt("line").toInt64();
        }
      }
    }
    if (backtrace.isNull()) {
      backtrace = stackTraceToBackTrace(e.getStackTrace());
    }
    try {
      ErrorStateHelper esh(this, ExecutingUserHandler);
      if (!same(f_call_user_func_array
                (m_userErrorHandlers.back().first,
                 CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
                                errline, "", backtrace)),
                false)) {
        return true;
      }
    } catch (...) {
      if (!swallowExceptions) throw;
    }
  }
  return false;
}
开发者ID:Bathrisyah,项目名称:hiphop-php,代码行数:44,代码来源:execution_context.cpp

示例11: 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

示例12: errorExit

void errorExit(Exception& e)
{
    cout << "Error: Failed" << endl << e.getMessage() << endl;
    exit(1);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:5,代码来源:AssociationTestProvider.cpp

示例13: Str

 Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
开发者ID:deleisha,项目名称:neopegasus,代码行数:1,代码来源:EnumerationContext.cpp

示例14: recordLastError

void BaseExecutionContext::recordLastError(const Exception &e,
                                           int errnum /* = 0 */) {
  m_lastError = String(e.getMessage());
  m_lastErrorNum = errnum;
}
开发者ID:Bathrisyah,项目名称:hiphop-php,代码行数:5,代码来源:execution_context.cpp

示例15: _writeException

void Translator::_writeException(const Exception& exception){
	_output << exception.getId() << std::endl;
	_output << exception.getMessage() << std::endl;
}
开发者ID:Chaosteil,项目名称:AwesomeScript,代码行数:4,代码来源:translator.cpp


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