private static string GetDeepestPowerShellFrame(Exception exception, int maxLength) { foreach (StackFrame frame in new StackTrace(exception).GetFrames()) { MethodBase method = frame.GetMethod(); if (method != null) { Module module = method.Module; if (module != null) { Type declaringType = method.DeclaringType; if (WindowsErrorReporting.IsPowerShellModule(module.Name, declaringType == null)) { return(WindowsErrorReporting.StackFrame2BucketParameter(frame, maxLength)); } } } } return(string.Empty); }
private static string GetDeepestFrame(Exception exception, int maxLength) => WindowsErrorReporting.StackFrame2BucketParameter(new StackTrace(exception).GetFrame(0), maxLength);