ErrorType Enumeration

Describes the possible types of errors.

XAML
<objectproperty="EnumerationValue" .../>
Scripting
value = "EnumerationValue"

Enumeration Values

Value Description
NoError No error.
UnknownError Error is unknwon.
InitializeError Error occurred during initalization.
ParserError Error occurred during the parsing of XAML content, at a level before the object model was incorporated. For example, tag mismatches in XML.
ObjectModelError Error occurred during the object model mapping of XAML content. For example, a name collision, or a required attribute was missing a value.
RuntimeError Error occurred in a synchronous method call inside a JavaScript function.
DownloadError Error occurred during package downloading.
MediaError Error occurred after a media file failed to load.
ImageError Error occurred after an image file failed to load.

Remarks

See Silverlight Application Scripting Error Handling to learn more about using values of this enumeration.

Examples

The following JavaScript example shows how to create an onError event handler that displays error information specific to the type of error that occurred. The ErrorType property on the ErrorEventArgs is used to determine the type of error.

JavaScript
function OnErrorEventHandler(sender, errorArgs)
{
    // The error message to display.
    var errorMsg = "Silverlight Error: \n\n";
    
    // Error information common to all errors.
    errorMsg += "Error Type:    " + errorArgs.errorType + "\n";
    errorMsg += "Error Message: " + errorArgs.errorMessage + "\n";
    errorMsg += "Error Code:    " + errorArgs.errorCode + "\n";
    
    // Determine the type of error and add specific error information.
    switch(errorArgs.errorType)
    {
        case "RuntimeError":
            // Display properties specific to RuntimeErrorEventArgs.
            if (errorArgs.lineNumber != 0)
            {
                errorMsg += "Line: " + errorArgs.lineNumber + "\n";
                errorMsg += "Position: " +  errorArgs.charPosition + "\n";
            }
            errorMsg += "MethodName: " + errorArgs.methodName + "\n";
            break;
        case "ParserError":
            // Display properties specific to ParserErrorEventArgs.
            errorMsg += "Xaml File:      " + errorArgs.xamlFile      + "\n";
            errorMsg += "Xml Element:    " + errorArgs.xmlElement    + "\n";
            errorMsg += "Xml Attribute:  " + errorArgs.xmlAttribute  + "\n";
            errorMsg += "Line:           " + errorArgs.lineNumber    + "\n";
            errorMsg += "Position:       " + errorArgs.charPosition  + "\n";
            break;
        default:
            break;
    }
    // Display the error message.
    alert(errorMsg);
}

Applies To

ErrorType

See Also

Silverlight Application Scripting Error Handling
ErrorEventArgs
ParserErrorEventArgs
RuntimeErrorEventArgs

Community Additions

Show: