<PackageReference Include="System.Drawing.Common" Version="10.0.0-preview.2.25163.9" />

ExceptionExtensions

static class ExceptionExtensions
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; using System.Runtime.Serialization; using System.Threading; namespace System { [NullableContext(1)] [Nullable(0)] internal static class ExceptionExtensions { internal static bool IsCriticalException(this Exception ex) { if (!(ex is NullReferenceException) && !(ex is StackOverflowException) && !(ex is OutOfMemoryException) && !(ex is ThreadAbortException) && !(ex is IndexOutOfRangeException) && !(ex is AccessViolationException)) return false; return true; } internal static SerializationException ConvertToSerializationException(this Exception ex) { TargetInvocationException ex2 = ex as TargetInvocationException; if (ex2 != null) ex = (ex2.InnerException ?? ex); SerializationException ex3 = ex as SerializationException; if (ex3 == null) return (SerializationException)ExceptionDispatchInfo.SetRemoteStackTrace(new SerializationException(ex.Message, ex), ex.StackTrace ?? string.Empty); return ex3; } } }