// If HRESULT code matches cached one for the current thread, throw the cached one. internal static void throwCached(int hresult) { NativeContext nc = Dispatcher.currentDispatcher?.synchronizationContext as NativeContext; if (null == nc?.cachedException) { return; } if (nc.cachedException.SourceException.HResult == hresult) { var ce = nc.cachedException; nc.cachedException = null; ce.Throw(); } }
internal static Exception tryGetCachedException(int hresult) { NativeContext nc = Dispatcher.currentDispatcher?.synchronizationContext as NativeContext; if (null == nc?.cachedException) { return(null); } if (nc.cachedException.SourceException.HResult == hresult) { var ce = nc.cachedException; nc.cachedException = null; return(ce.SourceException); } return(null); }
internal static void cacheException(Exception ex) { NativeContext nc = Dispatcher.currentDispatcher?.synchronizationContext as NativeContext; nc?.captureException(ex); }