예제 #1
0
//---------------------------------------------------------------------------
//	@function:
//		CAutoTaskProxy::PropagateError
//
//	@doc:
//		Propagate the error from sub task to current task
//
//---------------------------------------------------------------------------
void
CAutoTaskProxy::PropagateError
	(
		CTask *ptskSub
	)
{
	GPOS_ASSERT(m_fPropagateError);

	// sub-task must be in error status and have a pending exception
	GPOS_ASSERT(ITask::EtsError == ptskSub->Ets() && ptskSub->FPendingExc());

	CTask *ptskCur = CTask::PtskSelf();

	// current task must have no pending error
	GPOS_ASSERT(NULL != ptskCur && !ptskCur->FPendingExc());

	IErrorContext *perrctxtCur = ptskCur->Perrctxt();

	// copy necessary error info for propagation
	perrctxtCur->CopyPropErrCtxt(ptskSub->Perrctxt());

	// reset error of sub task
	ptskSub->Perrctxt()->Reset();

	// propagate the error
	CException::Reraise(perrctxtCur->Exc(), true /*fPropagate*/);
}
예제 #2
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__);
	}
}