Handling Warnings and Cases That Do Not Cause Exceptions

Reporting Services does not throw exceptions for warnings and certain errors. For example, when you use the CreateCatalogItem method to publish a new report to a report server, any warnings that occur are returned as an array of Warning objects. These warnings should be handled and displayed so that appropriate action can be taken.

Try
   rs.CreateCatalogItem(name, parentFolder, False, definition, Nothing, warnings)

   If Not (warnings.Length = 0) Then
      Dim warning As Warning
      For Each warning In warnings
         Console.WriteLine(warning.Message)
      Next warning
   Else
      Console.WriteLine("Report {0} created successfully with no warnings", name)
   End If

Catch ex As SoapException
   Console.WriteLine(ex.Detail("Message").InnerXml)
End Try
try
{
   rs.CreateCatalogItem("Report", name, parentFolder, false, definition, null, out warnings);

   if (warnings.Length != 0)
   {
      foreach (Warning warning in warnings)
      {
         Console.WriteLine(warning.Message);
      }
   }
   else
      Console.WriteLine("Report {0} created successfully with no warnings", name);
}

catch (SoapException ex)
{
   Console.WriteLine(ex.Detail["Message"].InnerXml);
}

Another way to handle errors is to evaluate the return values of certain methods. For example, the FindItems method can be used to search for specific items in the report server database. If no items are found that match the search criteria, a null array of CatalogItem objects is returned. You should evaluate the array, check for null, and let the user know if no items were found.

See Also

Reference

CatalogItem

Reporting Services SoapException Class

Other Resources

Introducing Exception Handling in Reporting Services