コード例 #1
0
ファイル: ncbiexpt.cpp プロジェクト: swuecho/igblast
void CExceptionReporterStream::Report(const char* file, int line,
    const string& title, const CException& ex, TDiagPostFlags flags) const
{
    SDiagMessage diagmsg(ex.GetSeverity(),
                         title.c_str(),
                         title.size(),
                         file,
                         line,
                         flags,
                         NULL,
                         0, 0,
                         ex.GetModule().c_str(),
                         ex.GetClass().c_str(),
                         ex.GetFunction().c_str());
    diagmsg.Write(m_Out);

    m_Out << "NCBI C++ Exception:" << endl;
    // invert the order
    stack<const CException*> pile;
    const CException* pex;
    for (pex = &ex; pex; pex = pex->GetPredecessor()) {
        pile.push(pex);
    }
    for (; !pile.empty(); pile.pop()) {
        pex = pile.top();
        m_Out << "    ";
        m_Out << pex->ReportThis(flags) << endl;
    }
}
コード例 #2
0
ファイル: except.cpp プロジェクト: rickerliang/OpenNT
// out-of-line implementation of CATCH and AND_CATCH
BOOL AFXAPI AfxCatchProc(CRuntimeClass* pClass)
{
	ASSERT(pClass != NULL);

	AFX_EXCEPTION_CONTEXT* pContext = AfxGetExceptionContext();
	ASSERT(pContext->m_pLinkTop != NULL);
	CException* pException = pContext->m_pLinkTop->m_pException;
	ASSERT(pException != NULL);

	return pException->IsKindOf(pClass);
}
コード例 #3
0
ファイル: macro.cpp プロジェクト: yodamaster/ycpp
static bool get_token(TCC_CONTEXT *tc, const char **line, CToken *token, bool for_include)
{
	bool retval;
	CException *ex = new CException;

	retval = ::ReadToken(tc, line, token, ex, for_include);
	if( ex->GetError() != NULL )
		throw ex;
	delete ex;
	return retval;
}
コード例 #4
0
ファイル: CWebApplication.cpp プロジェクト: djvibegga/yii-cws
void CWebApplication::renderException(const CException & e)
{
	CHttpResponse * response = getResponse();
#ifdef CWS_DEBUG
	string message = e.getFullMessage();
#else
	string message = e.getMessage();
#endif
	Cws::log(message, CLogger::LEVEL_ERROR);
	response->echo(utf8_to_(message));
}
コード例 #5
0
//---------------------------------------------------------------------------
//	@function:
//		CXformImplementAssert::Transform
//
//	@doc:
//		Actual transformation
//
//---------------------------------------------------------------------------
void
CXformImplementAssert::Transform
	(
	CXformContext *pxfctxt,
	CXformResult *pxfres,
	CExpression *pexpr
	)
	const
{
	GPOS_ASSERT(NULL != pxfctxt);
	GPOS_ASSERT(FPromising(pxfctxt->Pmp(), this, pexpr));
	GPOS_ASSERT(FCheckPattern(pexpr));

	IMemoryPool *pmp = pxfctxt->Pmp();

	// extract components
	CLogicalAssert *popAssert = CLogicalAssert::PopConvert(pexpr->Pop());
	CExpression *pexprRelational = (*pexpr)[0];
	CExpression *pexprScalar = (*pexpr)[1];
	CException *pexc = popAssert->Pexc();
	
	// addref all children
	pexprRelational->AddRef();
	pexprScalar->AddRef();
	
	// assemble physical operator
	CPhysicalAssert *popPhysicalAssert = 
			GPOS_NEW(pmp) CPhysicalAssert
						(
						pmp, 
						GPOS_NEW(pmp) CException(pexc->UlMajor(), pexc->UlMinor(), pexc->SzFilename(), pexc->UlLine())
						);
	
	CExpression *pexprAssert = 
		GPOS_NEW(pmp) CExpression
					(
					pmp, 
					popPhysicalAssert,
					pexprRelational,
					pexprScalar
					);
	
	// add alternative to results
	pxfres->Add(pexprAssert);
}
コード例 #6
0
ファイル: exceptions.cpp プロジェクト: radtek/isoftstone
std::string exception2string(const CException& e)
{
	std::string strMsg = std::string(e.what());
	if (strMsg.empty())
	{
		strMsg = std::string("空内容的 LCSH 标准异常");
	}
	return strMsg;
}
コード例 #7
0
ファイル: macro.cpp プロジェクト: yodamaster/ycpp
bool CMaExpander::ReadToken(CToken *token)
{
	bool retval;

	retval = ::ReadToken(tc, &pos, token, &gex, for_include);
	if( gex.GetError() != NULL )
		throw &gex;
	return retval;
}
コード例 #8
0
	ERMsg SYGetMessage(CException& e)
	{
		ERMsg message;

		TCHAR cause[255];
		e.GetErrorMessage(cause, 255);
		message.ajoute(UtilWin::ToUTF8(cause));

		return message;
	}
コード例 #9
0
//---------------------------------------------------------------------------
//	@function:
//		CErrorHandlerStandard::Process
//
//	@doc:
//		Process pending error context;
//
//---------------------------------------------------------------------------
void
CErrorHandlerStandard::Process
	(
	CException exc
	)
{
	CTask *ptsk = CTask::PtskSelf();

	GPOS_ASSERT(NULL != ptsk && "No task in current context");

	IErrorContext *perrctxt = ptsk->Perrctxt();
	CLogger *plog = dynamic_cast<CLogger*>(ptsk->PlogErr());
	
	GPOS_ASSERT(perrctxt->FPending() && "No error to process");
	GPOS_ASSERT(perrctxt->Exc() == exc && 
			"Exception processed different from pending");

	// print error stack trace
	if (CException::ExmaSystem == exc.UlMajor() && !perrctxt->FRethrow())
	{
		if ((CException::ExmiIOError == exc.UlMinor() ||
		    CException::ExmiNetError == exc.UlMinor() ) &&
			0 < errno)
		{
			perrctxt->AppendErrnoMsg();
		}

		if (ILogger::EeilMsgHeaderStack <= plog->Eil())
		{
			perrctxt->AppendStackTrace();
		}
	}

	// scope for suspending cancellation
	{
		// suspend cancellation
		CAutoSuspendAbort asa;

		// log error message
		plog->Log(perrctxt->WszMsg(), perrctxt->UlSev(), __FILE__, __LINE__);
	}
}
コード例 #10
0
ファイル: COptimizer.cpp プロジェクト: d/gporca
//---------------------------------------------------------------------------
//	@function:
//		COptimizer::HandleExceptionAfterFinalizingMinidump
//
//	@doc:
//		Handle exception after finalizing minidump
//
//---------------------------------------------------------------------------
void
COptimizer::HandleExceptionAfterFinalizingMinidump
	(
	CException &ex
	)
{
	if (NULL != ITask::PtskSelf() &&
		!ITask::PtskSelf()->Perrctxt()->FPending())
	{
		// if error context has no pending exception, then minidump creation
		// might have reset the error,
		// in this case we need to raise the original exception
		GPOS_RAISE
			(
			ex.UlMajor(),
			ex.UlMinor(),
			GPOS_WSZ_LIT("re-raising exception after finalizing minidump")
			);
	}

	// otherwise error is still pending, re-throw original exception
	GPOS_RETHROW(ex);
}
コード例 #11
0
ファイル: ErrorHandler.cpp プロジェクト: qunying/es40
void CErrorHandler::exception(const CException& exc)
{
	poco_debugger_msg(exc.what());
}
コード例 #12
0
ファイル: macro.cpp プロジェクト: yodamaster/ycpp
static void handle_define(TCC_CONTEXT *tc, sym_t mid, CMacro *ma)
{
	enum {
		STA_OKAY,
		STA_LEFT_PARENTHESIS,
		STA_PARAMETER,
		STA_SEPERATOR,
		STA_TRIDOT,
	} state;

	const char *line = ma->line;
	CToken token;

	if( ! get_token(tc, &line, &token, false) )
		return;

	if(token.attr == CToken::TA_IDENT) {
		if(*line == '(') {
			CC_ARRAY<sym_t>  para_list;
			XCHAR *xc;
			const char *last_pos;
			sym_t last_para = SSID_INVALID;
			bool has_va_args = false;
		
			state = STA_LEFT_PARENTHESIS;
			line++;
			while( get_token(tc, &line, &token, false) ) {
				switch(state) {
				case STA_LEFT_PARENTHESIS:	
					if( token.id == SSID_RIGHT_PARENTHESIS) {
						state = STA_OKAY;
						goto okay;
					} else if(token.attr == CToken::TA_IDENT) {
						para_list.push_back(token.id);
						state = STA_SEPERATOR;
					} else if(token.id == SSID_TRIDOT) {
						state = STA_TRIDOT;
						continue;
					} else {
						gEx.format("\"%s\" may not appear in macro parameter list", TR(tc,token.id));
						goto error;
					}
					break;
		
				case STA_SEPERATOR:
					if(token.id == SSID_RIGHT_PARENTHESIS) {
						state = STA_OKAY;
						goto okay;
					} else if(token.id == SSID_COMMA)
						state = STA_PARAMETER;
					else if(token.id == SSID_TRIDOT) {
						state = STA_TRIDOT;
					} else {
						gEx = "macro parameters must be comma-separated";
						goto error;
					}
					break;
		
				case STA_PARAMETER:
					if(token.id == SSID_TRIDOT) {
						state = STA_TRIDOT;
						continue;
					} else if(token.attr == CToken::TA_IDENT) {
						para_list.push_back(token.id);
						state = STA_SEPERATOR;
					} else {
						gEx = "parameter name missing";
						goto error;
					}
					break;

				case STA_TRIDOT:
					if(token.id != SSID_RIGHT_PARENTHESIS) {
						gEx = "missing ')' in macro parameter list";
						throw &gEx;
					}
					has_va_args = true;
					if(last_para == SSID_COMMA || last_para == SSID_LEFT_PARENTHESIS) {
						para_list.push_back(SSID_VA_ARGS);
						last_para = SSID_VA_ARGS;
					}
					goto okay;

				default:
					assert(0);
				}
				last_para = token.id;
			}

			if(state != STA_OKAY) {
				gEx = "missing ')' in macro parameter list";
				throw &gEx;
			}
		
		okay:
			xc = (XCHAR*) malloc(sizeof(XCHAR) * strlen(line) + 4);
			ma->id         = mid;
			ma->parsed     = xc;
			ma->nr_args    = para_list.size();
			ma->va_args    = has_va_args;

			skip_blanks(line);
			last_pos = line;
			sym_t prev_sid = SSID_INVALID;

			while(  ReadToken(tc, &line, &token, &gEx, false) ) {
				if(gEx.GetError() != NULL)
					throw (&gEx);
				
				if(token.id == SSID_DUAL_SHARP) {
					if(xc == ma->parsed) {
						gEx = "'##' cannot appear at either end of a macro expansion";
						goto error;
					} else if( IS_MA_PAR0(*(xc-1)) )
						*(xc-1) |= XF_MA_PAR2;
				}
				if(prev_sid == SSID_DUAL_SHARP) {
					XCHAR *yc = xc - 3;
					while( yc >= ma->parsed && (*yc == '\t' || *yc == ' ') )
						yc--;
					xc = yc + 1;
					assert(*xc == '#' || *xc == ' ' || *xc == '\t');
				}

				if( token.attr == CToken::TA_IDENT  ) {
					int magic = 0;
					int16_t para_ord;
					static const XCHAR xflags[3] = { XF_MA_PAR0, XF_MA_PAR1, XF_MA_PAR2 };

					if( has_va_args && (token.id == last_para || token.id == SSID_VA_ARGS) )
						para_ord = ma->nr_args - 1;
					else
						para_ord = find(token.id, para_list);
					if(prev_sid == SSID_SHARP) {
						if(para_ord < 0) {
							gEx = "'#' is not followed by a macro parameter";
							goto error;
						}
						magic = 1;
						xc--;
					} else if(prev_sid == SSID_DUAL_SHARP) {
						magic = 2;
					}
					if(para_ord < 0)
						goto do_cat;
					*xc++ = para_ord | xflags[magic];
				} else {
				do_cat:
					if(prev_sid == SSID_DUAL_SHARP) {
						skip_blanks(last_pos);
					}
					join(&xc, last_pos, line);
				}
				last_pos = line;
				prev_sid = token.id;
			} /*end while*/
			*xc = 0;
		} else {
			XCHAR *xc;

			xc = (XCHAR*) malloc(sizeof(XCHAR) * strlen(line) + 4);
			ma->id      = mid;
			ma->parsed  = xc;
			ma->nr_args = CMacro::OL_M;

			skip_blanks(line);
			while(1) {
				char c = *line;
				if( iseol(c) ) {
					*xc = '\0';
					break;
				}
				*xc = c;
				xc++, line++;
			}
		}
	}
//	dump(ma->parsed);
	return;

error:
	throw &gEx;
}
コード例 #13
0
ファイル: macro.cpp プロジェクト: yodamaster/ycpp
CC_STRING CMaExpander::Expand_FLM(CMacro *ma)
{
	CC_STRING outs;
	CC_ARRAY<CC_STRING> margs;
	CC_STRING carg;
	const char *p = pos;
	int level;

	skip_blanks(p);
	if( iseol(*p) ) {
		gex.format("Macro \"%s\" expects arguments", TR(tc,ma->id));
		throw &gex;
	}
	if( *p != '(' ) {
		gex = "Macro expects '('";
		throw &gex;
	}

	p++;
	skip_blanks(p);
	level = 1;
	while( 1 ) {
		if( iseol(*p) )
			break;

		if( *p == ','  ) {
			if( level == 1 && ( ! ma->va_args || (margs.size() + 1 < ma->nr_args) ) ) {
				Trim(carg);
				margs.push_back(carg);
				carg.clear();
			} else {
				carg += ',';
				skip_blanks(p);
			}
		} else if(*p == '(') {
			level ++;
			carg += '(';
		} else if(*p == ')') {
			level --;
			if(level == 0) {
				p++;
				Trim(carg);
				margs.push_back(carg);
				carg.clear();
				break;
			} else
				carg += ')';
		} else {
			carg += *p;
		}
		p++;
	}
	pos = p;

	XCHAR *xc;
	CC_STRING s;
	size_t n;

	n = ma->nr_args;
	assert(n != CMacro::OL_M);
	if(n != margs.size()) {
		if( ma->va_args && margs.size() + 1 == n ) {
			margs.push_back(CC_STRING(""));
		} else {
			gex.format("Macro \"%s\" requires %u arguments, but %u given",
				TR(tc,ma->id), n, margs.size() );
			throw &gex;
		}
	}

	for(xc = ma->parsed; *xc != 0; xc++) {
		if(IS_MA_PAR2(*xc) || IS_MA_PAR0(*xc)) {
			const CC_STRING& carg = margs[(uint8_t)*xc];
			CMaExpander expander2(tc, carg.c_str(), for_include);
			CC_STRING tmp;
			tmp = expander2.TryExpand();
			s += tmp;
		} else if(IS_MA_PAR1(*xc)) {
			const CC_STRING& carg = margs[(uint8_t)*xc];
			s += '"';
			s += carg;
			s += '"';
		} else {
			s += (char) *xc;
		}
	}
	outs += s;

	return outs;
}
コード例 #14
0
ファイル: Exception.cpp プロジェクト: SMR11/es40
CException::CException(const std::string& msg, const CException& nested, int code): _msg(msg), _pNested(nested.clone()), _code(code)
{
}