ExceptionRoutedEventArgs 클래스

정의

ImageFailed와 같은 비동기 작업에서 이벤트로 발생하는 예외에 대한 이벤트 데이터를 제공합니다.

public ref class ExceptionRoutedEventArgs : RoutedEventArgs
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ExceptionRoutedEventArgs : RoutedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class ExceptionRoutedEventArgs : RoutedEventArgs
Public Class ExceptionRoutedEventArgs
Inherits RoutedEventArgs
상속
Object Platform::Object IInspectable RoutedEventArgs ExceptionRoutedEventArgs
파생
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

이 예제에서는 HResult 및 오류 메시지를 가져오기 위해 처리기에서 ExceptionRoutedEventArgs를 사용하는 방법을 보여줍니다.

private void videoMediaElement_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
    // get HRESULT from event args 
    string hr = GetHresultFromErrorMessage(e);

    // Handle media failed event appropriately 
}

private string GetHresultFromErrorMessage(ExceptionRoutedEventArgs e)
{
    String hr = String.Empty;
    String token = "HRESULT - ";
    const int hrLength = 10;     // eg "0xFFFFFFFF"

    int tokenPos = e.ErrorMessage.IndexOf(token, StringComparison.Ordinal);
    if (tokenPos != -1)
    {
        hr = e.ErrorMessage.Substring(tokenPos + token.Length, hrLength);
    }

    return hr;
}

설명

최종 사용자에게 ErrorMessage 문자열을 표시하지 마세요. 대신 문자열 내의 부분 문자열 및 코드를 사용하여 오류 조건을 적극적으로 식별하고 앱이 적절한 작업을 수행하거나 앱 UI에 사용자 적절한 정보를 표시하도록 합니다.

ExceptionRoutedEventArgs는 ExceptionRoutedEventHandler 대리자를 사용하는 여러 이벤트에 대한 이벤트 데이터입니다. 여기에는 다음이 포함됩니다.

ExceptionRoutedEventArgs 파생 클래스

ExceptionRoutedEventArgs는 MediaFailedRoutedEventArgs의 부모 클래스입니다.

속성

ErrorMessage

예외의 메시지 구성 요소를 문자열로 가져옵니다.

OriginalSource

이벤트를 발생시킨 개체에 대한 참조를 가져옵니다. 앱 UI에서 선언된 요소가 아닌 컨트롤의 템플릿 부분입니다.

(다음에서 상속됨 RoutedEventArgs)

적용 대상

추가 정보