Some questions about Catch

Hey Guys, trying to properly implement Try Catch in a script I’m working on.

I’ve used Catch before, but never to catch a specific error.

From what I understand it should look like:

Try {Do-Thing}

Catch

{[ErrorType]

DoOther-Thing

}

Right now I am trying to create an error for parameter violation error, what do I need to put in the [ErrorType] to get it to recognize that error? I tried ParameterBindingValidationException but that didn’t work.

No, it’s more Try { Do-Thing } Catch [exception] { Whatever } Catch { Whatever }

The [exception] is a class type. There’s a good example in about_try_catch_finally. You almost have to cause the error once, grab the exception, and then look at it. Or, look up the exception class in MSDN.