Forum Discussion

ImanolCriado's avatar
ImanolCriado
New Contributor II
4 months ago

Prevent a Business Rule to stop when an error occurs

We are using an Extensibility Rule to import data from a database using a Stored Procedure (SP) within a do...while loop that modifies the SP parameters. The current implementation works as expected, but our customer has requested us to modify the Business Rule so it executes the SP with all the loop combinations, even if an error occurs during a single SP execution.

I attempted to implement this using nested Try...Catch blocks, so the error in the inner block does not get to the outer one. Unfortunately, it did not resolve the issue with this code structure:

Try
	(previous code, including do)
	Try 
		BRApi.Database.ExecuteSql(...)
	Catch ex As Exception
		log.AppendLine(...)
	End Try
	(more code, including while)
Catch 
	(general error handling)
End Try

The BR still terminates when an SP error occurs: am I missing something? is there a way to prevent the BR to stop when an error occurs?

Regards,

  • Hi, the inner block will catch the exception as you are capturing the generic Exception object The outer exception must be triggered by something else. What gets logged in the Error Log?  

  • Hi, the inner block will catch the exception as you are capturing the generic Exception object The outer exception must be triggered by something else. What gets logged in the Error Log?  

  • ImanolCriado's avatar
    ImanolCriado
    New Contributor II

    Hi SH_INT,

    You are absolutely right: the outer exception was triggered out of the inner block (specifically by the first line after the inner block).

    Thanks for your reply,
    Imanol