Example #1
0
//---------------------------------------------------------------------------
//	@function:
//		CException::Raise
//
//	@doc:
//		Throw/rethrow interface
//
//---------------------------------------------------------------------------
void
CException::Raise
	(
	CException exc
	)
{
#ifdef GPOS_DEBUG
	if (NULL != ITask::PtskSelf())
	{
		IErrorContext *perrctxt = ITask::PtskSelf()->Perrctxt();
		GPOS_ASSERT_IMP(perrctxt->FPending(), 
				perrctxt->Exc() == exc &&
				"Rethrow inconsistent with current error context");
	}
#endif // GPOS_DEBUG
	
	throw exc;
}
//---------------------------------------------------------------------------
//	@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__);
	}
}