Using the Detail Property to Handle Specific Errors
To further classify exceptions, Reporting Services returns additional error information in the InnerText property of the child elements in the SOAP exception's Detail property. Because the Detail property is an XmlNode object, you can access the inner text of the Message child element using the following code.
For a list of all of the available child elements contained in the Detail property, see Detail Property. For more information, see "Detail Property" in the Microsoft .NET Framework SDK documentation.
Try
' Code for accessing the report server
Catch ex As SoapException
' The exception is a SOAP exception, so use
' the Detail property's Message element.
Console.WriteLine(ex.Detail("Message").InnerXml)
End Try
try
{
// Code for accessing the report server
}
catch (SoapException ex)
{
// The exception is a SOAP exception, so use
// the Detail property's Message element.
Console.WriteLine(ex.Detail["Message"].InnerXml);
}
Try
' Code for accessing the report server
Catch ex As SoapException
If ex.Detail("ErrorCode").InnerXml = "rsInvalidItemName" Then
End If ' Perform an action based on the specific error code
End Try
try
{
// Code for accessing the report server
}
catch (SoapException ex)
{
if (ex.Detail["ErrorCode"].InnerXml == "rsInvalidItemName")
{
// Perform an action based on the specific error code
}
}
The following line of code writes the specific error code being returned in the SOAP Exception to the console. You could also evaluate the error code and perform specific actions.
Console.WriteLine(ex.Detail("ErrorCode").InnerXml)
Console.WriteLine(ex.Detail["ErrorCode"].InnerXml);
See Also