Custom Exceptions in BizTalk

Introduction

Think about a scenario in which we receive a response from a stored procedure and if the response is an error, we need to abort the transaction with a custom error message and route it to the catch block. We can accomplish this using custom error handling in BizTalk.

Steps:

In the orchestration code block where you need to capture the custom error, place an expression shape.

 



Now insert the below line of code in the Expression shape:

objException=new System.Exception(insertStatus);

 

"ObjException" is a variable of type 'System.Exception'



Below the expression shape, place a 'Throw Exception' shape with an exception object of 'ObjException.'



By doing this, we are throwing a custom exception, and the catch block will capture the custom errors and process them as configured in the catch block.

Comments

Popular posts from this blog

Error: Number of included segments do not match

REST API Calls with Query Parameters in BizTalk: A Step-by-Step Guide

EDI X12 Trading partner configuration in BizTalk