override public void Run() { Document doc = new Document(); doc.Add(new Field("content", "aaa", Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); while ((System.DateTime.Now.Ticks - 621355968000000000) / 10000 < stopTime) { for (int i = 0; i < 27; i++) { try { writer.AddDocument(doc); } catch (System.IO.IOException cie) { System.SystemException re = new System.SystemException("addDocument failed", cie); throw re; } } try { System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 1)); } catch (System.Threading.ThreadInterruptedException) { SupportClass.ThreadClass.Current().Interrupt(); } } }
public static void Ctor_String() { string message = "Created SystemException"; var exception = new SystemException(message); Assert.Equal(message, exception.Message); Assert.Equal(COR_E_SYSTEM, exception.HResult); }
public override bool Equals(object obj) { // See the full list of guidelines at // http://go.microsoft.com/fwlink/?LinkID=85237 // and also the guidance for operator== at // http://go.microsoft.com/fwlink/?LinkId=85238 if (obj == null || GetType() != obj.GetType()) { var exc = new System.SystemException("Warning, don't compare a struct to 'null' !!!"); UnityEngine.Debug.LogException(exc); throw exc; //return !isInitialized; } else { TimeStruct castedObj = (TimeStruct)obj; if (!isInitialized || !castedObj.isInitialized) { var exc = new System.SystemException("One of the TimeStructs is not initialized"); UnityEngine.Debug.LogException(exc); throw exc; } return(day == castedObj.day && hour == castedObj.hour && minute == castedObj.minute); } }
private static void ShowError(SystemException se) { Console.Error.WriteLine("* " + se.Message); if (se.InnerException != null) Console.Error.WriteLine("* " + se.InnerException.Message); if (se.Message.StartsWith("No application is associated")) Console.Error.WriteLine("* {0} only works with executables", _exeName); }
public static System.String searchFunction() { Console.Write("Enter Name of City: "); string city = Console.ReadLine(); SearchClass.setSearch(city); string link = SearchClass.getLink(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(link); try { HttpWebResponse response = (HttpWebResponse)req.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); string responseString = reader.ReadToEnd(); reader.Close(); responseStream.Close(); response.Close(); return responseString; } catch { Console.WriteLine("Bad Request"); SystemException error = new SystemException("Bad Request"); return error.ToString(); } }
public void ActorSubscriber_should_signal_error() { var e = new SystemException("simulated"); var actorRef = Source.FromEnumerator<int>(() => { throw e; }) .RunWith(Sink.ActorSubscriber<int>(ManualSubscriber.Props(TestActor)), Sys.Materializer()); actorRef.Tell("ready"); ExpectMsg<OnError>().Cause.Should().Be(e); }
public static void Ctor_String_Exception() { string message = "Created SystemException"; var innerException = new Exception("Created inner exception"); var exception = new SystemException(message, innerException); Assert.Equal(message, exception.Message); Assert.Equal(COR_E_SYSTEM, exception.HResult); Assert.Equal(innerException, exception.InnerException); Assert.Equal(innerException.HResult, exception.InnerException.HResult); }
private void Act() { try { _channel.Open(); } catch (SystemException ex) { _actualException = ex; } }
public static TimeStruct operator -(TimeStruct time1, TimeStruct time2) { if (!time1.isInitialized || !time2.isInitialized) { var exc = new System.SystemException("One of the TimeStructs is not initialized"); UnityEngine.Debug.LogException(exc); throw exc; } return(time1 + (-time2)); }
public static void Log(string message, string source = null, string user = null) { try { var exception = new SystemException(); Log(exception, message, 0, source, user); } catch(Exception) { } }
public void A_WatchTermination_must_fail_the_future_when_stream_is_failed() { this.AssertAllStagesStopped(() => { var ex = new SystemException("Stream failed."); var t = this.SourceProbe<int>().WatchTermination(Keep.Both).To(Sink.Ignore<int>()).Run(Materializer); var p = t.Item1; var future = t.Item2; p.SendNext(1); p.SendError(ex); future.Invoking(f => f.Wait()).ShouldThrow<SystemException>().WithMessage("Stream failed."); }, Materializer); }
public static bool operator >(TimeStruct time1, TimeStruct time2) { if (!time1.isInitialized || !time2.isInitialized) { var exc = new System.SystemException("One of the TimeStructs is not initialized"); UnityEngine.Debug.LogException(exc); throw exc; } return(time1.day > time2.day || (time1.day == time2.day && time1.hour > time2.hour) || (time1.hour == time2.hour && time1.minute > time2.minute)); }
public void Failed_Source_must_emit_error_immediately() { var ex = new SystemException(); var p = Source.Failed<int>(ex).RunWith(Sink.AsPublisher<int>(false), Materializer); var c = TestSubscriber.CreateManualProbe<int>(this); p.Subscribe(c); c.ExpectSubscriptionAndError(); //reject additional subscriber var c2 = TestSubscriber.CreateManualProbe<int>(this); p.Subscribe(c2); c2.ExpectSubscriptionAndError(); }
public static void ShowTrustRelationshipError(SystemException exception) { if(exception.Message.Contains("The trust relationship between this workstation and the primary domain failed")) { var popup = CustomContainer.Get<IPopupController>(); popup.Header = "Error connecting to server"; popup.Description = "This computer cannot contact the Domain Controller." + Environment.NewLine + "If it does not belong to a domain, please ensure it is removed from the domain in computer management."; popup.Buttons = MessageBoxButton.OK; popup.ImageType = MessageBoxImage.Error; popup.Show(); } }
// Simple test to verify locking system is "working". On // NFS, if it's misconfigured, you can hit long (35 // second) timeouts which cause Lock.obtain to take far // too long (it assumes the obtain() call takes zero // time). private void AcquireTestLock() { lock (this) { if (tested) { return; } tested = true; // Ensure that lockDir exists and is a directory. bool tmpBool; if (System.IO.File.Exists(lockDir.FullName)) { tmpBool = true; } else { tmpBool = System.IO.Directory.Exists(lockDir.FullName); } if (!tmpBool) { try { System.IO.Directory.CreateDirectory(lockDir.FullName); } catch { throw new System.SystemException("Cannot create directory: " + lockDir.FullName); } } else if (!System.IO.Directory.Exists(lockDir.FullName)) { throw new System.SystemException("Found regular file where directory expected: " + lockDir.FullName); } System.String randomLockName = "lucene-" + System.Convert.ToString(new System.Random().Next(), 16) + "-test.lock"; Lock l = MakeLock(randomLockName); try { l.Obtain(); l.Release(); } catch (System.IO.IOException e) { System.SystemException e2 = new System.SystemException("Failed to acquire random test lock; please verify filesystem for lock directory '" + lockDir + "' supports locking", e); throw e2; } } }
static StaticData() { // Exception created but is not thrown TestCreatedException = new SystemException("System Test Exception"); // Traditional created and throw exception try { throw new RankException("Rank Test"); } catch (RankException e) { TestThrowException = e; } // Exception containing inner exceptions try { try { try { throw new TypeAccessException("Test Type Exception"); } catch (TypeAccessException exp1) { throw new DivideByZeroException("Divide By Zero Test", exp1); } } catch (DivideByZeroException exp2) { throw new ArithmeticException("Inner Exception Test", exp2); } } catch (ArithmeticException exp3) { TestInnerException = exp3; } // Exception with a defined stack trace var callClass = new TestNamespace.ClassAlpha(); try { callClass.ThrowException(); } catch (TimeoutException exp) { TestCallStackException = exp; } }
/// <summary> /// Identify if a particular SystemException is one of the exceptions which may be thrown /// by the Lync Model API. /// </summary> /// <param name="ex"></param> /// <returns></returns> internal static bool IsLyncException(SystemException ex) { return ex is NotImplementedException || ex is ArgumentException || ex is NullReferenceException || ex is NotSupportedException || ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException || ex is InvalidOperationException || ex is TypeLoadException || ex is TypeInitializationException || ex is InvalidComObjectException || ex is InvalidCastException; }
public static void Cozy() { Console.WriteLine("\n-----------------------------------------------"); Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); Console.WriteLine("-----------------------------------------------"); System.Exception e1 = new Exception(); System.ApplicationException e2 = new ApplicationException(); e2 = null; System.Reflection.TargetInvocationException e3 = new TargetInvocationException(e1); System.SystemException e4 = new SystemException(); e4 = null; System.StackOverflowException e5 = new StackOverflowException(); e5 = null; }
public static TimeStruct operator +(TimeStruct time1, TimeStruct time2) { if (!time1.isInitialized || !time2.isInitialized) { var exc = new System.SystemException("One of the TimeStructs is not initialized"); UnityEngine.Debug.LogException(exc); throw exc; } TimeStruct res = new TimeStruct( time1.day + time2.day, time1.hour + time2.hour, time1.minute + time2.minute); return(res); }
protected override void ProcessRecord() { ErrorRecord _error; if (ErrorRecord != null) { _error = ErrorRecord; } else { Exception _exception; if (Exception != null) _exception = Exception; else _exception = new SystemException(Message); if (String.IsNullOrEmpty(ErrorId)) _error = new ErrorRecord(_exception, _exception.GetType().FullName, Category, TargetObject); else _error = new ErrorRecord(_exception, ErrorId, Category, TargetObject); //if (!String.IsNullOrEmpty(RecommendedAction)) // _error.ErrorDetails.RecommendedAction = RecommendedAction; } if (!String.IsNullOrEmpty(CategoryTargetType)) _error.CategoryInfo.TargetType = CategoryTargetType; if (!String.IsNullOrEmpty(CategoryReason)) _error.CategoryInfo.Reason = CategoryReason; if (!String.IsNullOrEmpty(CategoryActivity)) _error.CategoryInfo.Activity = CategoryActivity; if (!String.IsNullOrEmpty(CategoryTargetName)) _error.CategoryInfo.TargetName = CategoryTargetName; WriteError(_error); }
public static int ExceptionReporter(SystemException e) { string ExceptionMessage = "An exception has occured: " + e + ".@Contine?@@ABORT to Close Program.@RETRY to reset Browser and continue.@IGNORE to ignore error and continue."; ExceptionMessage = ExceptionMessage.Replace("@", WinSys.Environment.NewLine); if (MessageBox.Show(ExceptionMessage, "Waiolib Error handler.", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error) == DialogResult.Abort) { return 0; } else if (MessageBox.Show(ExceptionMessage, "Waiolib Error handler.", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error) == DialogResult.Retry) { return 1; } else { Core.ExceptionHandlerCrash(); return 2; } }
public override object Clone() { MultiMMapIndexInput clone = (MultiMMapIndexInput)base.Clone(); clone.isClone = true; clone.buffers = new System.IO.MemoryStream[buffers.Length]; // No need to clone bufSizes. // Since most clones will use only one buffer, duplicate() could also be // done lazy in clones, e.g. when adapting curBuf. for (int bufNr = 0; bufNr < buffers.Length; bufNr++) { clone.buffers[bufNr] = buffers[bufNr]; // clone.buffers[bufNr] = buffers[bufNr].duplicate(); // {{Aroush-1.9}} how do we clone?! } try { clone.Seek(FilePointer); } catch (System.IO.IOException ioe) { System.SystemException newException = new System.SystemException(ioe.Message, ioe); throw newException; } return(clone); }
private void ShowError(SystemException se) { string msg = se.Message; if (se.InnerException != null) msg += "\r\n" + se.InnerException.Message; MessageBox.Show(msg, "TouchRemoteOptions", MessageBoxButtons.OK, MessageBoxIcon.Error); }
// Simple test to verify locking system is "working". On // NFS, if it's misconfigured, you can hit long (35 // second) timeouts which cause Lock.obtain to take far // too long (it assumes the obtain() call takes zero // time). private void AcquireTestLock() { lock (this) { if (tested) return ; tested = true; // Ensure that lockDir exists and is a directory. bool tmpBool; if (System.IO.File.Exists(lockDir.FullName)) tmpBool = true; else tmpBool = System.IO.Directory.Exists(lockDir.FullName); if (!tmpBool) { try { System.IO.Directory.CreateDirectory(lockDir.FullName); } catch { throw new System.SystemException("Cannot create directory: " + lockDir.FullName); } } else if (!System.IO.Directory.Exists(lockDir.FullName)) { throw new System.SystemException("Found regular file where directory expected: " + lockDir.FullName); } System.String randomLockName = "lucene-" + System.Convert.ToString(new System.Random().Next(), 16) + "-test.lock"; Lock l = MakeLock(randomLockName); try { l.Obtain(); l.Release(); } catch (System.IO.IOException e) { System.SystemException e2 = new System.SystemException("Failed to acquire random test lock; please verify filesystem for lock directory '" + lockDir + "' supports locking", e); throw e2; } } }
private void ShowMultiMinerRemotingError(SystemException ex) { BeginInvoke((Action)(() => { //code to update UI string message = "MultiMiner Remoting communication failed"; PostNotification(message, message, () => { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }, ToolTipIcon.Error); })); }
private static void Error(SystemException se) { Console.Error.WriteLine(se.Message); if (se.InnerException != null) Console.Error.WriteLine(se.InnerException.Message); }
public void InputStreamSink_should_return_Exception_when_stream_is_failed() { this.AssertAllStagesStopped(() => { var sinkProbe = CreateTestProbe(); var t = this.SourceProbe<ByteString>().ToMaterialized(TestSink(sinkProbe), Keep.Both).Run(_materializer); var probe = t.Item1; var inputStream = t.Item2; var ex = new SystemException("Stream failed."); probe.SendNext(_byteString); sinkProbe.ExpectMsg<GraphStageMessages.Push>(); var r = ReadN(inputStream, _byteString.Count); r.Item1.Should().Be(_byteString.Count); r.Item2.ShouldBeEquivalentTo(_byteString); probe.SendError(ex); sinkProbe.ExpectMsg<GraphStageMessages.Failure>().Ex.Should().Be(ex); var task = Task.Run(() => inputStream.ReadByte()); Action block = () => task.Wait(Timeout); block.ShouldThrow<Exception>(); task.Exception.InnerException.Should().Be(ex); }, _materializer); }
public void GetExplicitBaseExceptionWithInnerExceptions() { Exception dbzEx = new DivideByZeroException(); Exception sEx = new SystemException("Test message", dbzEx); Exception appEx = new ApplicationException("Test message", sEx); Exception ex = ReflectionUtils.GetExplicitBaseException(appEx); Assert.AreEqual(ex, dbzEx); }
/// <summary> Clears the current target error conditions, if any. Note that a thread /// in the pool might have set the error conditions since the last check /// and that those error conditions will be lost. Likewise, before /// returning from this method another thread might set the error /// conditions. There is no guarantee that no error conditions exist when /// returning from this method. /// /// <P>In order to ensure that no error conditions exist when returning /// from this method cooperation from the targets and the thread using this /// pool is necessary (i.e. currently no targets running or waiting to /// run). /// /// </summary> public virtual void clearTargetErrors() { // Clear the error and runtime exception conditions targetE = null; targetRE = null; }
public void Execute_5_Dependencies() { _resolverMock.Resolve<string>().Returns("str-dep-1"); _resolverMock.Resolve<long>().Returns(42); _resolverMock.Resolve<int>().Returns(12); var dep4 = new FlagsAttribute(); _resolverMock.Resolve<FlagsAttribute>().Returns(dep4); var dep5 = new SystemException(); _resolverMock.Resolve<SystemException>().Returns(dep5); var queryMock = Substitute.For<IQuery<int, string, long, int, FlagsAttribute, SystemException>>(); _queryExecutor.Execute(queryMock); queryMock.Received().Execute("str-dep-1", 42, 12, dep4, dep5); }
protected override void ProcessRecord() { string sddlForm; ObjectSecurity objectSecurity = this.securityDescriptor as ObjectSecurity; if (this.inputObject == null) { if (this.Path != null) { if (objectSecurity != null) { if ((this.CentralAccessPolicy != null || this.ClearCentralAccessPolicy) && !DownLevelHelper.IsWin8AndAbove()) { Exception parameterBindingException = new ParameterBindingException(); base.WriteError(new ErrorRecord(parameterBindingException, "SetAcl_OperationNotSupported", ErrorCategory.InvalidArgument, null)); return; } else { if (this.CentralAccessPolicy == null || !this.ClearCentralAccessPolicy) { IntPtr zero = IntPtr.Zero; NativeMethods.TOKEN_PRIVILEGE tOKENPRIVILEGE = new NativeMethods.TOKEN_PRIVILEGE(); try { if (this.CentralAccessPolicy == null) { if (this.ClearCentralAccessPolicy) { zero = this.GetEmptySacl(); if (zero == IntPtr.Zero) { SystemException systemException = new SystemException(UtilsStrings.GetEmptySaclFail); base.WriteError(new ErrorRecord(systemException, "SetAcl_ClearCentralAccessPolicy", ErrorCategory.InvalidResult, null)); return; } } } else { zero = this.GetSaclWithCapId(this.CentralAccessPolicy); if (zero == IntPtr.Zero) { SystemException systemException1 = new SystemException(UtilsStrings.GetSaclWithCapIdFail); base.WriteError(new ErrorRecord(systemException1, "SetAcl_CentralAccessPolicy", ErrorCategory.InvalidResult, null)); return; } } string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; Collection<PathInfo> pathInfos = new Collection<PathInfo>(); CmdletProviderContext cmdletProviderContext = base.CmdletProviderContext; cmdletProviderContext.PassThru = this.Passthru; if (!this.isLiteralPath) { pathInfos = base.SessionState.Path.GetResolvedPSPathFromPSPath(str, base.CmdletProviderContext); } else { ProviderInfo providerInfo = null; PSDriveInfo pSDriveInfo = null; string unresolvedProviderPathFromPSPath = base.SessionState.Path.GetUnresolvedProviderPathFromPSPath(str, out providerInfo, out pSDriveInfo); pathInfos.Add(new PathInfo(pSDriveInfo, providerInfo, unresolvedProviderPathFromPSPath, base.SessionState)); cmdletProviderContext.SuppressWildcardExpansion = true; } foreach (PathInfo pathInfo in pathInfos) { if (!base.ShouldProcess(pathInfo.Path)) { continue; } try { base.InvokeProvider.SecurityDescriptor.Set(pathInfo.Path, objectSecurity, cmdletProviderContext); if (this.CentralAccessPolicy != null || this.ClearCentralAccessPolicy) { if (pathInfo.Provider.NameEquals(base.Context.ProviderNames.FileSystem)) { IntPtr tokenWithEnabledPrivilege = this.GetTokenWithEnabledPrivilege("SeSecurityPrivilege", tOKENPRIVILEGE); if (tokenWithEnabledPrivilege != IntPtr.Zero) { int num = NativeMethods.SetNamedSecurityInfo(pathInfo.ProviderPath, NativeMethods.SeObjectType.SE_FILE_OBJECT, NativeMethods.SecurityInformation.SCOPE_SECURITY_INFORMATION, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, zero); if (tokenWithEnabledPrivilege != IntPtr.Zero) { NativeMethods.TOKEN_PRIVILEGE tOKENPRIVILEGE1 = new NativeMethods.TOKEN_PRIVILEGE(); uint num1 = 0; NativeMethods.AdjustTokenPrivileges(tokenWithEnabledPrivilege, false, ref tOKENPRIVILEGE, Marshal.SizeOf(tOKENPRIVILEGE1), ref tOKENPRIVILEGE1, ref num1); NativeMethods.CloseHandle(tokenWithEnabledPrivilege); } if (num != 0) { SystemException win32Exception = new Win32Exception(num, UtilsStrings.SetCentralAccessPolicyFail); base.WriteError(new ErrorRecord(win32Exception, "SetAcl_SetNamedSecurityInfo", ErrorCategory.InvalidResult, null)); } } else { SystemException systemException2 = new SystemException(UtilsStrings.GetTokenWithEnabledPrivilegeFail); base.WriteError(new ErrorRecord(systemException2, "SetAcl_AdjustTokenPrivileges", ErrorCategory.InvalidResult, null)); return; } } else { Exception argumentException = new ArgumentException("Path"); base.WriteError(new ErrorRecord(argumentException, "SetAcl_Path", ErrorCategory.InvalidArgument, this.AclObject)); continue; } } } catch (NotSupportedException notSupportedException) { object[] objArray = new object[1]; objArray[0] = pathInfo.Path; ErrorRecord errorRecord = SecurityUtils.CreateNotSupportedErrorRecord(UtilsStrings.OperationNotSupportedOnPath, "SetAcl_OperationNotSupported", objArray); base.WriteError(errorRecord); } } } return; } finally { Marshal.FreeHGlobal(zero); } } else { Exception exception = new ArgumentException(UtilsStrings.InvalidCentralAccessPolicyParameters); ErrorRecord errorRecord1 = SecurityUtils.CreateInvalidArgumentErrorRecord(exception, "SetAcl_OperationNotSupported"); base.WriteError(errorRecord1); return; } } } else { Exception argumentException1 = new ArgumentException("AclObject"); base.WriteError(new ErrorRecord(argumentException1, "SetAcl_AclObject", ErrorCategory.InvalidArgument, this.AclObject)); return; } } else { Exception exception1 = new ArgumentException("Path"); base.WriteError(new ErrorRecord(exception1, "SetAcl_Path", ErrorCategory.InvalidArgument, this.AclObject)); } } else { PSMethodInfo item = this.inputObject.Methods["SetSecurityDescriptor"]; if (item == null) { ErrorRecord errorRecord2 = SecurityUtils.CreateNotSupportedErrorRecord(UtilsStrings.SetMethodNotFound, "SetAcl_OperationNotSupported", new object[0]); base.WriteError(errorRecord2); return; } else { CommonSecurityDescriptor commonSecurityDescriptor = this.securityDescriptor as CommonSecurityDescriptor; if (objectSecurity == null) { if (commonSecurityDescriptor == null) { Exception argumentException2 = new ArgumentException("AclObject"); base.WriteError(new ErrorRecord(argumentException2, "SetAcl_AclObject", ErrorCategory.InvalidArgument, this.AclObject)); return; } else { sddlForm = commonSecurityDescriptor.GetSddlForm(AccessControlSections.All); } } else { sddlForm = objectSecurity.GetSecurityDescriptorSddlForm(AccessControlSections.All); } try { object[] objArray1 = new object[1]; objArray1[0] = sddlForm; item.Invoke(objArray1); return; } catch (Exception exception3) { Exception exception2 = exception3; CommandProcessorBase.CheckForSevereException(exception2); ErrorRecord errorRecord3 = SecurityUtils.CreateNotSupportedErrorRecord(UtilsStrings.MethodInvokeFail, "SetAcl_OperationNotSupported", new object[0]); base.WriteError(errorRecord3); } } } }
public FactoryException(string message, SystemException inner) : base(message, inner) { }
public override System.Object Clone() { MultiMMapIndexInput clone = (MultiMMapIndexInput) base.Clone(); clone.isClone = true; clone.buffers = new System.IO.MemoryStream[buffers.Length]; // No need to clone bufSizes. // Since most clones will use only one buffer, duplicate() could also be // done lazy in clones, e.g. when adapting curBuf. for (int bufNr = 0; bufNr < buffers.Length; bufNr++) { clone.buffers[bufNr] = buffers[bufNr]; // clone.buffers[bufNr] = buffers[bufNr].duplicate(); // {{Aroush-1.9}} how do we clone?! } try { clone.Seek(GetFilePointer()); } catch (System.IO.IOException ioe) { System.SystemException newException = new System.SystemException(ioe.Message, ioe); throw newException; } return clone; }
private void ShowMultiMinerRemotingError(SystemException ex) { Context.BeginInvoke((Action)(() => { //code to update UI const string message = "MultiMiner Remoting communication failed"; PostNotification(message, () => { MessageBoxShow(ex.Message, "Error", PromptButtons.OK, PromptIcon.Error); }, NotificationKind.Danger); }), null); }
/// <summary> /// Gets the detaild message from a System Exception. /// </summary> /// <param name="ex">The ex.</param> /// <returns></returns> private string GetDetaildMessage(SystemException ex) { string errorMessage = String.Empty; //if we can get more specific details, do it... if (ex is DbEntityValidationException) { List<DbEntityValidationResult> validationErrors = this._db.GetValidationErrors().ToList(); foreach (DbEntityValidationResult currResult in validationErrors) { //get the error message List<DbValidationError> errors = currResult.ValidationErrors.ToList(); List<String> errorString = errors.Select(error => error.ErrorMessage).ToList(); errorMessage += String.Join(Environment.NewLine, errorString); } //errorMessage = String.Join(Environment.NewLine,this._db.GetValidationErrors().ToList()); } else { errorMessage = ex.Message; } return errorMessage; }
public void Throttle_for_various_cost_elements_must_handle_rate_calculation_function_exception() { this.AssertAllStagesStopped(() => { var ex = new SystemException(); Source.From(Enumerable.Range(1, 5)) .Throttle(2, TimeSpan.FromMilliseconds(200), 0, _ => { throw ex; }, ThrottleMode.Shaping) .Throttle(1, TimeSpan.FromMilliseconds(100), 5, ThrottleMode.Enforcing) .RunWith(this.SinkProbe<int>(), Materializer) .Request(5) .ExpectError().Should().Be(ex); }, Materializer); }