本文整理汇总了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
}
示例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);
}
示例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);
}
示例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);
}
示例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() + "::";
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
//.........这里部分代码省略.........
示例12: errorExit
void errorExit(Exception& e)
{
cout << "Error: Failed" << endl << e.getMessage() << endl;
exit(1);
}
示例13: Str
Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
示例14: recordLastError
void BaseExecutionContext::recordLastError(const Exception &e,
int errnum /* = 0 */) {
m_lastError = String(e.getMessage());
m_lastErrorNum = errnum;
}
示例15: _writeException
void Translator::_writeException(const Exception& exception){
_output << exception.getId() << std::endl;
_output << exception.getMessage() << std::endl;
}