/// <summary> /// Enters to the protected code section. Throws user exception if termination was requested /// </summary> /// <typeparam name="TException">The type of exception to throw when attempt was unsuccessful</typeparam> /// <returns>Guard primitive to track the protected section scope with 'using' statement</returns> public EntryCountingEventGuard Enter <TException>() where TException : Exception { if (!TryEnterClientCore()) { TurboException.Throw <TException>(); } return(new EntryCountingEventGuard(this)); }
private void TestTypedExceptionWithoutMessage <TExc>() where TExc : Exception { try { TurboException.Throw <TExc>(); Assert.Fail("Should throw exception"); } catch (Exception ex) { Assert.IsTrue(ex.GetType() == typeof(TExc)); } }
/// <summary> /// Enters to the protected code section. Throws user exception if termination was requested /// </summary> /// <typeparam name="TException">The type of exception to throw when attempt was unsuccessful</typeparam> /// <param name="message">Message, that will be passed to Exception constructor</param> /// <returns>Guard primitive to track the protected section scope with 'using' statement</returns> public EntryCountingEventGuard Enter<TException>(string message) where TException: Exception { if (!TryEnterClientCore()) TurboException.Throw<TException>(message); return new EntryCountingEventGuard(this); }
public void TestWithNonExceptionType() { TurboException.Throw(typeof(int), "message"); }