public static void LogHelper_Current_WritingException(object sender, LogHelperEventArgs e) { if (!enabled) { e.Cancel = true; } var ex = e.Exception as SharpDX.SharpDXException; var d = ex?.Descriptor; if (d != null) { // If exception when getting Joystick properties in // CustomDiState.cs class: var o = device.GetObjectInfoByOffset((int)list[i]); if (d.ApiCode == "NotFound" && d.Code == -2147024894 && d.Module == "SharpDX.DirectInput" && d.NativeApiCode == "DIERR_NOTFOUND" ) { // Cancel reporting error. e.Cancel = true; } // If another DInput errors } var fex = e.Exception as FileNotFoundException; // If serializer warning then... if (fex != null && fex.HResult == unchecked ((int)0x80070002) && fex.FileName.Contains(".XmlSerializers")) { // Cancel reporting error. e.Cancel = true; } ControlsHelper.GetActiveControl(_TopControl, out var activeControl, out var activePath); // Add path to current control to help with error fixing. e.Exception.Data.Add("ActiveControlPath", activePath); }