This is just a pointer to a couple of relevant pages
https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Core/about/about_Try_Catch_Finally
http://www.vexasoft.com/blogs/powershell/7255220-powershell-tutorial-try-catch-finally-and-error-handling-in-powershell