February 2019
Intermediate to advanced
626 pages
15h 51m
English
The throw keyword raises a terminating error, as in the following example:
throw 'Error message'
Existing exception types are documented in the .NET framework; each is ultimately derived from the System.Exception type found in the .NET reference:
https://docs.microsoft.com/en-us/dotnet/api/system.exception?view=netframework-4.7.2
throw may be used with a string or a message, as shown previously. throw may also be used with an exception object:
throw [ArgumentException]::new('Unsupported value')
Or it may be used with ErrorRecord:
throw [System.Management.Automation.ErrorRecord]::new( [InvalidOperationException]::new('Invalid operation'), 'AnErrorID', [System.Management.Automation.ErrorCategory]::InvalidOperation, ...Read now
Unlock full access