コード例 #1
0
ファイル: Thread.cpp プロジェクト: bsletten/monarch
void Thread::setException(ExceptionRef& e, bool caused)
{
   // initialize threads
   pthread_once(&sThreadsInit, &initializeThreads);

   // get the exception reference for the current thread
   ExceptionRef* ref =
      static_cast<ExceptionRef*>(pthread_getspecific(sExceptionKey));
   if(ref == NULL)
   {
      // create the exception reference
      ref = new ExceptionRef(NULL);
      *ref = e;
      pthread_setspecific(sExceptionKey, ref);
   }
   else
   {
      if(caused && !e.isNull())
      {
         // set cause of passed exception to previous exception
         e->setCause(*ref);
      }

      // update the reference
      *ref = e;
   }
}
コード例 #2
0
bool AbstractConnection::rollback()
{
    bool rval = false;

    // save the reason for the rollback
    ExceptionRef reason = Exception::get();

    // attempt to do the rollback
    Statement* s = prepare("ROLLBACK");
    rval = (s != NULL) && s->execute() && s->reset();
    if(!rval)
    {
        ExceptionRef e = new Exception(
            "Could not rollback transaction.",
            "monarch.sql.Connection.TransactionRollbackError");
        if(!reason.isNull())
        {
            e->getDetails()["rollbackReason"] =
                Exception::convertToDynamicObject(reason);
        }
        Exception::push(e);
    }

    return rval;
}
コード例 #3
0
ファイル: Thread.cpp プロジェクト: bsletten/monarch
bool Thread::hasException()
{
   bool rval = false;

   // initialize threads
   pthread_once(&sThreadsInit, &initializeThreads);

   // get the exception reference for the current thread
   ExceptionRef* ref =
      static_cast<ExceptionRef*>(pthread_getspecific(sExceptionKey));
   if(ref != NULL)
   {
      // return true if the reference isn't to NULL
      rval = !ref->isNull();
   }

   return rval;
}