ICoreApplicationUnhandledError.UnhandledErrorDetected 이벤트

정의

비동기 완료 처리기 또는 시스템 또는 앱 코드에서 처리되지 않은 이벤트 처리기에 오류가 있을 때 발생합니다.

// Register
event_token UnhandledErrorDetected(EventHandler<UnhandledErrorDetectedEventArgs> const& handler) const;

// Revoke with event_token
void UnhandledErrorDetected(event_token const* cookie) const;

// Revoke with event_revoker
ICoreApplicationUnhandledError::UnhandledErrorDetected_revoker UnhandledErrorDetected(auto_revoke_t, EventHandler<UnhandledErrorDetectedEventArgs> const& handler) const;
event System.EventHandler<UnhandledErrorDetectedEventArgs> UnhandledErrorDetected;
function onUnhandledErrorDetected(eventArgs) { /* Your code */ }
iCoreApplicationUnhandledError.addEventListener("unhandlederrordetected", onUnhandledErrorDetected);
iCoreApplicationUnhandledError.removeEventListener("unhandlederrordetected", onUnhandledErrorDetected);
- or -
iCoreApplicationUnhandledError.onunhandlederrordetected = onUnhandledErrorDetected;
Event UnhandledErrorDetected As EventHandler(Of UnhandledErrorDetectedEventArgs) 

이벤트 유형

설명

이 이벤트는 시스템 또는 앱 코드에서 처리하지 않고 스택 맨 위에 도달하는 비동기 완료 또는 이벤트 처리기에 오류가 발생할 때마다 발생합니다. 앱에서 오류를 검사하고 오류를 처리됨으로 표시할지 여부를 선택할 수 있습니다(이벤트 데이터에서 Handled 속성을 사용). 오류가 처리됨으로 표시되면 실행이 계속됩니다. 오류가 처리됨으로 표시되지 않으면 프로세스가 종료됩니다.

Windows::ApplicationModel::Core::CoreApplication::UnhandledErrorDetected([](auto&&, auto&& args)
{
    if (!args.UnhandledError().Handled())
    {
        try
        {
            // Take the failure HRESULT and wrap it in a language specific exception.
            args.UnhandledError().Propagate();
        }
        catch (winrt::hresult_error const& e)
        {
            MyLogger::Log(e.message());
            // Since UnhandledError.Propagate marks the error as Handled, rethrow in order to only Log and not Handle.
            throw e;
        }
    }
});
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;
        }
    }
});

적용 대상

추가 정보