From 2a12fb53e556fd557125f0d46762abe3b6bb0e27 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Sun, 9 Dec 2018 20:53:32 -0800 Subject: [PATCH] Remove unneeded catch/throw from 'mkdir' and 'oss' functions (#8425) --- .../engine/InitialSessionState.cs | 65 +++++-------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index f19f806529..f86b2869e5 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4186,36 +4186,18 @@ param( ) begin { - - try { - $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('New-Item', [System.Management.Automation.CommandTypes]::Cmdlet) - $scriptCmd = {& $wrappedCmd -Type Directory @PSBoundParameters } - $steppablePipeline = $scriptCmd.GetSteppablePipeline() - $steppablePipeline.Begin($PSCmdlet) - } catch { - throw - } - + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('New-Item', [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd -Type Directory @PSBoundParameters } + $steppablePipeline = $scriptCmd.GetSteppablePipeline() + $steppablePipeline.Begin($PSCmdlet) } process { - - try { - $steppablePipeline.Process($_) - } catch { - throw - } - + $steppablePipeline.Process($_) } end { - - try { - $steppablePipeline.End() - } catch { - throw - } - + $steppablePipeline.End() } "; @@ -4234,35 +4216,20 @@ param( [psobject] ${InputObject}) -begin -{ - try { - $PSBoundParameters['Stream'] = $true - $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Out-String',[System.Management.Automation.CommandTypes]::Cmdlet) - $scriptCmd = {& $wrappedCmd @PSBoundParameters } - $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin) - $steppablePipeline.Begin($PSCmdlet) - } catch { - throw - } +begin { + $PSBoundParameters['Stream'] = $true + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Out-String',[System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters } + $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) } -process -{ - try { - $steppablePipeline.Process($_) - } catch { - throw - } +process { + $steppablePipeline.Process($_) } -end -{ - try { - $steppablePipeline.End() - } catch { - throw - } +end { + $steppablePipeline.End() } <# .ForwardHelpTargetName Out-String