Try/Catch Blocks

Welcome Forums General PowerShell Q&A Try/Catch Blocks

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
5 years, 3 months ago.

  • Author
    Posts
  • #9651

    Participant
    Points: 1
    Rank: Member

    Simple question. Guess I could test it and see what happens, but right now (honestly) I barely have time to post this question. I'm getting tired of 70-hour weeks!
    Can a catch block contain it's own try/catch code? I want to do some cleanup in the catch (not the finally) in case an error occurred, but it is possible that the cleanup code itself could error. I may handle this with a error action preference of Silently Continue, but in the meantime, am just interested to know if I can use try/catch within a catch.

  • #9652

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    Sure.

The topic ‘Try/Catch Blocks’ is closed to new replies.