Windows apps
Collapse the table of content
Expand the table of content

ErrorCode

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the error code that is associated with an error.

value = eventargs.ErrorCode

Type: integer

The error code of the event.

This property is read-only.

Error handling in the managed API is reported by exceptions, which do not use the error codes (although they may in some cases be reported as part of the exception message).

For a listing of error codes, their meanings, and error strings, see Silverlight Plug-in Error Messages.

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

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

Community Additions

Show:
© 2017 Microsoft