ExceptionRoutedEventArgs class
Collapse the table of content
Expand the table of content

ExceptionRoutedEventArgs class

[ Updated for UWP apps on Windows 10. For Windows 8.x articles, see the archive ]

Provides event data for exceptions that are raised as events by asynchronous operations, such as ImageFailed.

Inheritance

Object
  RoutedEventArgs
    ExceptionRoutedEventArgs

Syntax


public class ExceptionRoutedEventArgs : RoutedEventArgs

Members

The ExceptionRoutedEventArgs class has these types of members:

Methods

The ExceptionRoutedEventArgs class inherits methods from the Object class.

Properties

The ExceptionRoutedEventArgs class has these properties.

PropertyAccess typeDescription

ErrorMessage

Read-onlyGets the message component of the exception, as a string.

OriginalSource

Read-onlyGets a reference to the object that raised the event. This is often a template part of a control rather than an element that was declared in your app UI. (Inherited from RoutedEventArgs)

 

Remarks

Don't display ErrorMessage strings to end users. Instead, use substrings and codes within the string to positively identify the error condition, and have your app take appropriate action or display user-appropriate information in the app UI.

ExceptionRoutedEventArgs is the event data for several events that use the ExceptionRoutedEventHandler delegate. These include:

ExceptionRoutedEventArgs derived classes

ExceptionRoutedEventArgs is the parent class for MediaFailedRoutedEventArgs.

Examples

This example shows use of ExceptionRoutedEventArgs in a handler in order to get the HResult and error message.


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;
}


Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

See also

Object
RoutedEventArgs
MediaFailed
ImageFailed

 

 

Show:
© 2016 Microsoft