Exemple #1
0
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;
   }
}
Exemple #2
0
ExceptionRef Exception::convertToException(DynamicObject& dyno)
{
   ExceptionRef rval = new Exception(
      dyno["message"]->getString(),
      dyno["type"]->getString());

   if(dyno->hasMember("cause"))
   {
      ExceptionRef cause = convertToException(dyno["cause"]);
      rval->setCause(cause);
   }

   if(dyno->hasMember("details"))
   {
      *(*rval).mDetails = dyno["details"].clone();
   }

   return rval;
}