Share via


Usar la propiedad Detail para administrar errores concretos

Para clasificar más las excepciones, Reporting Services devuelve información de error adicional en la propiedad InnerText de los elementos secundarios en la propiedad Detail de la excepción SOAP. Dado que la propiedad Detail es un objeto XmlNode, puede tener acceso al texto interno del elemento secundario Message utilizando el código siguiente.

Para obtener una lista de todos los elementos secundarios disponibles contenidos en la propiedad Detail, vea Propiedad Detail. Para obtener más información, vea "Propiedad Detail" en la documentación de Microsoft .NET Framework SDK.

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

La línea de código siguiente escribe el código de error concreto que se va a devolver en la excepción SOAP para la consola. Podría evaluar también el código de error y realizar acciones específicas.

Console.WriteLine(ex.Detail("ErrorCode").InnerXml)
Console.WriteLine(ex.Detail["ErrorCode"].InnerXml);