I​Core​Application​Unhandled​Error I​Core​Application​Unhandled​Error I​Core​Application​Unhandled​Error I​Core​Application​Unhandled​Error Interface

Definition

Adds an error handling event for global error handling from the system that app models can use.

public : interface ICoreApplicationUnhandledErrorpublic interface ICoreApplicationUnhandledErrorPublic Interface ICoreApplicationUnhandledError// This API is not available in Javascript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The ICoreApplicationUnhandledError mechanism for error handling is primarily for C++ developers who are using Microsoft DirectX. For Windows Store app using C++, C#, or Visual Basic you should handle UnhandledException, which is exposed by the Application object in that app model.

Most scenarios won't use this interface for either implementation or casting. Instead, most app scenarios will use CoreApplication.UnhandledErrorDetected or similar events provided by the app models for UI frameworks.

Events

UnhandledErrorDetected UnhandledErrorDetected UnhandledErrorDetected UnhandledErrorDetected

Occurs when there is an error in an async completion or event handler that wasn't otherwise handled by system or app code.

public : abstract event EventHandler UnhandledErrorDetected<UnhandledErrorDetectedEventArgs>public abstract event EventHandler UnhandledErrorDetected<UnhandledErrorDetectedEventArgs>Public MustInherit Event UnhandledErrorDetected<UnhandledErrorDetectedEventArgs>// This API is not available in Javascript.

Remarks

This event is raised whenever there is an error in an async completion or event handler that reaches top of stack without being handled by system or app code. Your app can inspect the error and choose whether to mark the error as handled (using the Handled property in event data). If the error is marked Handled, execution will continue. If the error is not marked Handled, the process will be terminated.

CoreApplication::UnhandledErrorDetected += ref new EventHandler<UnhandledErrorDetectedEventArgs^ > ( 
  [](Platform::Object^ sender, UnhandledErrorDetectedEventArgs^ ea) -> 
  {
    if(!ea->UnhandledError->Handled)
    {
      try
      {
         // Take the failure HRESULT and wrap it in a language specific exception
         ea->UnhandledError->Propagate();
      } 
      catch (Platform::Exception^ e)
      {  
         MyLogger::Log(e->Message);
         // Since UnhandledError.Propagate marks the error as Handled, rethrow in order to only Log and not Handle
         throw e;
      }
    }
  });