Can you give me a scenario- why do we need to use rethrow?

If we can handle exception in catch,why do we need to rethrow that exception again? What is the need for that? In what kind of project should we use that

The Rethrow activity allows you to throw the exception currently being handled by a Catch path. This is useful if you wish to perform some error processing, but then propagate the error up to the next level.

Also, check this post How to use Throw and ReThrow

1 Like

because you might have common error handling logic e.g. send email

Simple example:
main calls process1 & process2

if we rethrow errors from process1&2 to main, then we only need to handle the errors in main.xaml

if we dont rethrow, we need logic to send email in process1 & process2. Meaning code will be repeated

2 Likes

Qn is why we need to do that? Why we need to propagate to next level.very confusing.without scenario,not getting it bro

Yah.i got it now.as we can also handle errors in process1 and process2,but we are using rethrow so that we don’t have to repeat the same activities again and again in individual processes right?

1 Like

yes, youre right

1 Like

Thankss bro!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.