views:

164

answers:

3

How to create an unqualified catch block in Dynamics AX ?

This is said dev help for AX2009sp1, but there is no example of it. All valid catch blocks need the exception type as mandatory parameter, for instance:

catch(exception::error) 
{ 
   : 
}

have I missed something? br,

A: 

I don't know AX, but I can offer some suggestions; you could try omitting the exception parameter all together (i.e. catch() {...}, or using the most generally type possible for the exception parameter (i.e. object or the equivalent in your language). That's at least how it works in many other languages.

MarkusQ
A: 

"One strategy is to have the last catch statement leave the exception type unspecified"

http://msdn.microsoft.com/en-us/library/aa893385.aspx

sholsinger
+1  A: 

You should leave the catch clause without parameter.

try
{
   //...      
}
catch
{
   //... 
}

Here is an excelent screencast on exception handling:

http://channel9.msdn.com/posts/mfp/Exception-handling-in-X/

Velislav Marinov

related questions