Utilizzare la proprietà Detail per gestire errori specifici
Per classificare ulteriormente le eccezioni, Reporting Services restituisce altre informazioni sull'errore nella proprietà InnerText degli elementi figlio nella proprietà Detail dell'eccezione SOAP. Poiché la proprietà Detail è un oggetto XmlNode, è possibile accedere al testo interno dell'elemento figlio Message usando il codice seguente.
Per un elenco di tutti gli elementi figlio disponibili inclusi nella proprietà Detail, vedere Detail Property. Per ulteriori informazioni, vedere "Proprietà Detail" nella documentazione di 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
}
}
Tramite la riga di codice seguente viene scritto il codice di errore specifico restituito nell'eccezione SOAP alla console. È anche possibile valutare il codice di errore ed eseguire azioni specifiche.
Console.WriteLine(ex.Detail("ErrorCode").InnerXml)
Console.WriteLine(ex.Detail["ErrorCode"].InnerXml);