Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Nested Try/Catch design approaches

(0) ShareShare
ReportReport
Posted on by 23

Hi All.

 

The organisation I'm working for have set up a basic flow template structure which essentially compresses of a top-level try / catch scope.  The 'try' would contain all the main actions of the flow, with the 'catch' handling failure & timeouts, and translates the cause of the failure and notifies an administrator via email.  This was primarily done because we had a number of flows that were faulting and we weren't aware of them.

 

However, I'm working on a number of new flows, while trying to adopt this established template structure, where some actions will legitimately fail, and decisions need to be executed based on these legitimate failures.  The problem that I am having is that these legitimate fails are triggering the 'catch' error handling.

 

In essence, what I really want to do is have nested try/catches as you would in other, traditional programming languages / environments.  I've tried this approach and it makes no difference - any failure eventually percolates down to the top-level 'catch' scope.

 

Does anyone have any design suggestions (other than split everything) or is it possible to cancel a failure some how so it doesn't cascade down?

 

Many thanks in advance

 

Mike

  • MC-05081019-0 Profile Picture
    MC-05081019-0 23 on at
    Re: Nested Try/Catch design approaches

    Hay Chriddle,

     

    Thanks for the help and support.  I've replicated exactly what you have done and I can confirm that it works as you have stated, and solves my problem.

     

    It seems that by adding the 'finally' scope, on the internal try/catch, and setting its run after to include everything, it effectively mutes the failure and prevents it from filtering down to the external try/catch.  Without the inclusion of this 'finally' scope, any internal failures progress on to the external catch.

     

    In some ways this logic makes sense (I guess) but its also a little illogical.  In other programming paradigms, a 'catch' statement would intercept an exception (or all exceptions) and potentially handle them, without them progressing outside of the catch statement.

     

    Anyway, all sorted now - thank you for your help

  • Chriddle Profile Picture
    Chriddle 7,336 on at
    Re: Nested Try/Catch design approaches

    There is nothing special in my flow.
    Each Try scope's run after is set to ["is successfuel"], each Catch scope is set to ["has failed", "has timed out"]
    and each Finally has checked all options.

     

    If the last action of a scope fails, then the scope fails. Maybe your inner catch fails? Without a "Finally" this would cause the outer Catch to run.

     

     

  • MC-05081019-0 Profile Picture
    MC-05081019-0 23 on at
    Re: Nested Try/Catch design approaches

    Exactly like that...

     

    How did you achieve it? 🙂

     

    I have a top-level try/catch scope, and if I add another try/catch scope within the main (top-level) try scope, configured in exactly the same manner (i.e. the 'catch' is set to run on failure or timeout) any failure in the internal 'try' filters down to both 'catches'...

  • Chriddle Profile Picture
    Chriddle 7,336 on at
    Re: Nested Try/Catch design approaches

    Something like this?

    Chriddle_1-1687795559372.png

     

    I always add a "Finally" so I only need to mess with runafter settings within these scopes.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard