GetInstance() public static method

Gets the instance data associated with the exception
public static GetInstance ( Exception e ) : RubyExceptionData
e System.Exception
return RubyExceptionData
Beispiel #1
0
 public static Exception /*!*/ InitializeException(Exception /*!*/ exception, object message)
 {
     // only set it if message is non-null. Otherwise, let lazy initialization create the default message from CLR exception message
     if (message != null)
     {
         RubyExceptionData.GetInstance(exception).Message = message;
     }
     return(exception);
 }
Beispiel #2
0
        public static void ActiveExceptionHandled(Exception visibleException)
        {
            Debug.Assert(RubyUtils.GetVisibleException(visibleException) == visibleException);

            RubyExceptionData data = RubyExceptionData.GetInstance(visibleException);

            if (data._exception != visibleException)
            {
                // The exception was raised asynchronously with Thread.Abort. We can not just catch and ignore
                // the ThreadAbortException as the CLR keeps trying to re-raise it unless ResetAbort is called.
                //
                // Note that ResetAbort can cause ThreadAbortException.ExceptionState to be cleared (though it may
                // not be cleared under some circustances), and we use that to squirrel away the Ruby exception
                // that the user is expecting. Hence, ResetAbort should only be called when
                // ThreadAbortException.ExceptionState no longer needs to be accessed.
                if ((Thread.CurrentThread.ThreadState & System.Threading.ThreadState.AbortRequested) != 0)
                {
                    Thread.ResetAbort();
                }
            }
        }