Databases Reference
In-Depth Information
Following the methodology of error handling offered by the .NET Framework,
ADOMD.NET uses an exception-handling mechanism to work with errors. When an error
is encountered, an exception is thrown by the object model, and the client application
has to catch and process it. The client application either continues the execution or passes
the error message to the user.
Because you are already familiar with programming languages in the .NET family, you
know that you should put the code that might cause an exception inside try instructions,
and wrap the error-handling code in a catch instruction. The .NET Framework also
provides the finally instruction, in which you should place code that has to be executed
regardless of whether an exception is thrown. For example, a program written in C#
would look like this:
try
{
// Execute some code.
}
catch(Exception exception)
{
// Handle the error
}
finally
{
// Operations for clearing resources, for example, to close the connections
}
ADOMD.NET has a special class for error handling: AdomdException . A client application
that calls ADOMD.NET objects should be ready to catch this kind of exception from any call
to ADOMD.NET. The application should also be prepared for other standard types of excep-
tions to be thrown by ADOMD.NET, such as NotSupportedException , InvalidOperation
Exception , and ArgumentNullException . These types of exceptions usually imply misuse of
the object model; that is, the problem is in the client application code.
To enable the client application to handle different types of errors in dissimilar ways,
ADOMD.NET provides special classes derived from AdomdException . The remainder of the
chapter discusses those special classes.
AdomdErrorResponseException
AdomdErrorResponseException is thrown when a request sent to the server has failed and
the server has returned an error message to the client. An erroneous MDX request can be
one of the many reasons for this exception. An AdomdErrorResponseException object
contains a collection of the AdomdError objects. Each AdomdError object gives information
about the error—its code, message, and path or URL to the file containing the help infor-
mation about the error. An AdomdError object also contains information about the loca-
tion in the request where the syntax error occurred. Figure 33.22 displays the hierarchy of
objects contained in AdomdErrorResponseException .
Search WWH ::




Custom Search