Caliburn.Micro icon indicating copy to clipboard operation
Caliburn.Micro copied to clipboard

Async Methods swallow exceptions

Open vb2ae opened this issue 1 year ago • 1 comments

This pull request introduces several changes to improve exception handling across various files in the Caliburn.Micro framework. The most significant changes include adding exception handling mechanisms in asynchronous methods and updating the ResultCompletionEventArgs class to include an exception property.

Exception Handling Enhancements:

  • src/Caliburn.Micro.Core/Screen.cs: Added try-catch blocks in ActivateAsync, DeactivateAsync, and other methods to log exceptions and call new virtual methods for handling exceptions. [1] [2] [3] [4]
  • src/Caliburn.Micro.Core/ResultCompletionEventArgs.cs: Introduced a private _exception field and a constructor to initialize it.

Coroutine Exception Handling:

  • src/Caliburn.Micro.Platform/Platforms/Android/CaliburnApplication.cs: Added a CoroutineException method to handle exceptions during coroutine execution.
  • src/Caliburn.Micro.Platform/Platforms/Maui/Android/CaliburnApplication.cs: Added CoroutineException method and updated Initialize method to subscribe to Coroutine.Completed event. [1] [2]
  • src/Caliburn.Micro.Platform/Platforms/net46-netcore/Bootstrapper.cs: Added CoroutineException method and updated Initialize method to handle coroutine exceptions. [1] [2]

Miscellaneous Changes:

  • src/Caliburn.Micro.Platform/Platforms/Maui/FormsApplication.cs: Added CoroutineException method and updated Initialize method to handle coroutine exceptions. [1] [2]
  • src/Caliburn.Micro.Platform/Platforms/netcore-avalonia/BootstrapperBase.cs: Added CoroutineException method and updated Initialize method to handle coroutine exceptions. [1] [2]

These changes enhance the robustness of the framework by ensuring that exceptions are properly logged and handled, preventing potential crashes and improving debugging capabilities.

Closing #863, #745

vb2ae avatar Jan 01 '25 17:01 vb2ae

@darxis Hope you had a Happy New Year. Could you look at this when you get a chance?

vb2ae avatar Jan 01 '25 18:01 vb2ae