Monday, January 28, 2008

Exception Handling in Orchestrations

It might be basic knowledge for some, but for a BizTalk-newbie it can be useful information... ;-)

If you want to access the error message in a catch-block, you should do it like this:
  1. Set the "Exception Object Type" of the catch-block to "System.Exception" (can be found in the mscorlib).
  2. Set the "Exception Object Name" of the catch-block to "ex".
  3. In any expression inside the catch-block, you can now use code such as ex.Message, ex.StackTrace, ...

If you want to throw a new exception, you can use the ThrowException shape. This shape can be a little confusing though. It has an "Exception Object" property which you assign using a drop-down list. When you first drag the shape onto your orchestration, the only item in the list is "General Exception". If you wish to throw a specific exception, you need to create a variable of an exception type. This variable will then be displayed in the drop-down list.

No comments: