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

Community Additions

ADD
Show: