diff --git a/Documents/Changelog/Changelog.md b/Documents/Changelog/Changelog.md index 3debcfa63..a9ad9f584 100644 --- a/Documents/Changelog/Changelog.md +++ b/Documents/Changelog/Changelog.md @@ -3,6 +3,8 @@ ======= ## 2025-11-xx - Build 2511 - November 2025 +* Implemented [#1968](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1968), Open up 'ExceptionHandler' for public use + - To invoke, use `KryptonExceptionHandler` * Resolved [#560](https://github.com/Krypton-Suite/Standard-Toolkit/issues/560), CheckBox Images are not scaled with dpi Awareness * Resolved [#565](https://github.com/Krypton-Suite/Standard-Toolkit/issues/565), GroupBox icons are not scaled for dpi awareness * Resolved [#559](https://github.com/Krypton-Suite/Standard-Toolkit/issues/559), Header group icon is not scaled for dpi awareness diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs index 5778229e5..f77a90020 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs @@ -2246,7 +2246,7 @@ public void ImportWithUpgrade(string themeFilePath) } catch (Exception e) { - ExceptionHandler.CaptureException(e); + KryptonExceptionHandler.CaptureException(e); } finally { @@ -2295,7 +2295,7 @@ private void PerformUpgrade(Stream stream) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -3260,7 +3260,7 @@ private void ImportFromXmlDocument([DisallowNull] XmlDocument doc) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } finally { @@ -3400,7 +3400,7 @@ private XmlDocument ExportToXmlDocument(bool ignoreDefaults) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); return new XmlDocument(); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonExceptionHandler.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonExceptionHandler.cs new file mode 100644 index 000000000..b77c594a6 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonExceptionHandler.cs @@ -0,0 +1,50 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp), Simon Coghlan(aka Smurf-IV), Giduac, et al. 2024 - 2025. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// + [ToolboxItem(false)] + [DesignerCategory(@"code")] + public static class KryptonExceptionHandler + { + #region Public + + /// Captures the exception. + /// The exception. + /// The title. + /// The caller file path. + /// The line number. + /// The caller method. + /// if set to true [show stack trace]. + /// The use exception dialog. + public static void CaptureException(Exception exception, + string title = "Exception Caught", + [CallerFilePath] string callerFilePath = "", + [CallerLineNumber] int lineNumber = 0, + [CallerMemberName] string callerMethod = "", + bool showStackTrace = false, bool? useExceptionDialog = true) => + ExceptionHandler.CaptureException(exception, title, callerFilePath, lineNumber, callerMethod, + showStackTrace, useExceptionDialog); + + /// Prints the stack trace. + /// The exception. + /// Name of the file. + public static void PrintStackTrace(Exception exception, string fileName) => + ExceptionHandler.PrintStackTrace(exception, fileName); + + /// Prints the exception stack trace. + /// The exception. + /// Name of the file. + public static void PrintExceptionStackTrace(Exception exception, string fileName) => + ExceptionHandler.PrintExceptionStackTrace(exception, fileName); + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolBarManager.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolBarManager.cs index 6809b6ba6..e6e581677 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolBarManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolBarManager.cs @@ -378,7 +378,7 @@ public void ShowIntegrateToolBar(bool showIntegratedToolBar, KryptonForm parentF } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -404,7 +404,7 @@ public void AttachIntegratedToolBarToParent(KryptonForm? parentForm) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -431,7 +431,7 @@ public void DetachIntegratedToolBarFromParent(KryptonForm? parentForm) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -489,7 +489,7 @@ public void UpdateButtonOrientation(PaletteButtonOrientation buttonOrientation) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -529,7 +529,7 @@ public void UpdateButtonAlignment(PaletteRelativeEdgeAlign buttonAlignment) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToolkitPoweredByControl.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToolkitPoweredByControl.cs index ede90aa79..cdb44329f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToolkitPoweredByControl.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToolkitPoweredByControl.cs @@ -121,7 +121,7 @@ private void klwlblDetails_LinkClicked(object sender, LinkLabelLinkClickedEventA } catch (Exception exception) { - ExceptionHandler.CaptureException(exception, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(exception, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCustomPaletteBaseActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCustomPaletteBaseActionList.cs index ff8ee3410..e238ee633 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCustomPaletteBaseActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCustomPaletteBaseActionList.cs @@ -135,7 +135,7 @@ private void OnUpgradePalette(object? sender, EventArgs e) } catch (Exception exc) { - ExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCustomPaletteBaseDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCustomPaletteBaseDesigner.cs index 0032542ec..7914cc7fc 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCustomPaletteBaseDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCustomPaletteBaseDesigner.cs @@ -113,7 +113,7 @@ private void OnUpgrade(object? sender, EventArgs e) } catch (Exception exc) { - ExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/General/IntegratedToolbarManager.cs b/Source/Krypton Components/Krypton.Toolkit/General/IntegratedToolbarManager.cs index a63c5a604..54fadbb20 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/IntegratedToolbarManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/IntegratedToolbarManager.cs @@ -64,7 +64,7 @@ internal void SetupToolBar() } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -79,7 +79,7 @@ internal void ShowToolBar(bool visible) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs index 37a37a302..be4199180 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs @@ -72,7 +72,7 @@ public static void ApplyGlobalTheme(KryptonManager manager, PaletteMode paletteM } catch (Exception exc) { - ExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -128,7 +128,7 @@ public static void LoadCustomTheme(KryptonCustomPaletteBase palette, KryptonMana } catch (Exception exc) { - ExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(exc, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/GlobalToolkitUtilities.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/GlobalToolkitUtilities.cs index a5e0711de..012dbf526 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/GlobalToolkitUtilities.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/GlobalToolkitUtilities.cs @@ -33,7 +33,7 @@ public static void LaunchProcess(string processName) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -48,7 +48,7 @@ public static void LaunchProcess(string processName, string arguments) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } } @@ -62,7 +62,7 @@ public static void LaunchProcess(string processName, string arguments) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } return null; @@ -92,7 +92,7 @@ public static void LaunchProcess(string processName, string arguments) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } return null; diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs index d0d049226..c017db274 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs @@ -41,7 +41,7 @@ public static class GraphicsExtensions { //Console.WriteLine("Unable to extract the icon from the binary"); - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } return result; @@ -106,7 +106,7 @@ public static Icon LoadIcon(IconType type, Size size) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); return null; } @@ -157,7 +157,7 @@ public static Icon LoadIcon(IconType type, Size size) } catch (Exception ex) { - ExceptionHandler.CaptureException(ex, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(ex, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); // /* EXTRACT ICON ERROR */ //// BUBBLE UP diff --git a/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs b/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs index 83acd6501..bdb4f33ad 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs @@ -219,7 +219,7 @@ private void LaunchProcess(string processPath) } catch (Exception e) { - ExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); + KryptonExceptionHandler.CaptureException(e, showStackTrace: GlobalStaticValues.DEFAULT_USE_STACK_TRACE); } }