internal static Exception CreateExceptionToRaise(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ storage0, BinaryOpStorage/*!*/ storage1, SetBacktraceStorage/*!*/ setBackTraceStorage, RubyContext/*!*/ context, object/*!*/ obj, object arg, RubyArray backtrace) { if (Protocols.RespondTo(respondToStorage, context, obj, "exception")) { Exception e = null; if (arg != Missing.Value) { var site = storage1.GetCallSite("exception"); e = site.Target(site, context, obj, arg) as Exception; } else { var site = storage0.GetCallSite("exception"); e = site.Target(site, context, obj) as Exception; } if (e != null) { if (backtrace != null) { RubyExceptionData.GetInstance(e).SetBacktrace(setBackTraceStorage.GetCallSite(), context, backtrace); } return e; } } throw RubyExceptions.CreateTypeError("exception class/object expected"); }
public static void RaiseException(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ storage0, BinaryOpStorage/*!*/ storage1, SetBacktraceStorage/*!*/ setBackTraceStorage, RubyContext/*!*/ context, Thread/*!*/ self, object/*!*/ obj, [Optional]object arg, [Optional]RubyArray backtrace) { if (self == Thread.CurrentThread) { KernelOps.RaiseException(respondToStorage, storage0, storage1, setBackTraceStorage, context, self, obj, arg, backtrace); return; } #if SILVERLIGHT throw new NotImplementedError("Thread#raise is not implemented on Silverlight"); #else Exception e = KernelOps.CreateExceptionToRaise(respondToStorage, storage0, storage1, setBackTraceStorage, context, obj, arg, backtrace); RaiseAsyncException(self, e); #endif }
public static void RaiseException(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ storage0, BinaryOpStorage/*!*/ storage1, SetBacktraceStorage/*!*/ setBackTraceStorage, RubyContext/*!*/ context, object self, object/*!*/ obj, [Optional]object arg, [Optional]RubyArray backtrace) { Exception exception = CreateExceptionToRaise(respondToStorage, storage0, storage1, setBackTraceStorage, context, obj, arg, backtrace); #if DEBUG && !SILVERLIGHT if (RubyOptions.UseThreadAbortForSyncRaise) { RubyUtils.RaiseAsyncException(Thread.CurrentThread, exception); } #endif // rethrow semantics, preserves the backtrace associated with the exception: throw exception; }