Skip to content

Commit ca54d49

Browse files
committed
Fix code formatting
1 parent d5347a8 commit ca54d49

File tree

3 files changed

+45
-60
lines changed

3 files changed

+45
-60
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ block.
118118
PowerShell does not recognize "NonsenseString" as a cmdlet or other item.
119119
Running this script returns the following result:
120120

121-
```powershell
121+
```Output
122122
An error occurred.
123123
```
124124

@@ -133,16 +133,13 @@ two `catch` blocks:
133133

134134
```powershell
135135
try {
136-
$wc = New-Object System.Net.WebClient
137-
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
138-
}
139-
catch [System.Net.WebException],[System.IO.IOException] {
136+
$wc = New-Object System.Net.WebClient
137+
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
138+
} catch [System.Net.WebException],[System.IO.IOException] {
140139
"Unable to download MyDoc.doc from http://www.contoso.com."
141-
}
142-
catch {
140+
} catch {
143141
"An error occurred that could not be resolved."
144142
}
145-
146143
```
147144

148145
The first `catch` block handles errors of the **System.Net.WebException** and
@@ -156,8 +153,9 @@ from the specified class. The following example contains a `catch` block that
156153
catches a "Command Not Found" error:
157154

158155
```powershell
159-
catch [System.Management.Automation.CommandNotFoundException]
160-
{"Inherited Exception" }
156+
catch [System.Management.Automation.CommandNotFoundException] {
157+
"Inherited Exception"
158+
}
161159
```
162160

163161
The specified error type, **CommandNotFoundException**, inherits from the
@@ -197,8 +195,8 @@ also known as `$PSItem`. The object is of type **ErrorRecord**.
197195
```powershell
198196
try { NonsenseString }
199197
catch {
200-
Write-Host "An error occurred:"
201-
Write-Host $_
198+
Write-Host "An error occurred:"
199+
Write-Host $_
202200
}
203201
```
204202

@@ -218,8 +216,8 @@ change the script to the following:
218216
```powershell
219217
try { NonsenseString }
220218
catch {
221-
Write-Host "An error occurred:"
222-
Write-Host $_.ScriptStackTrace
219+
Write-Host "An error occurred:"
220+
Write-Host $_.ScriptStackTrace
223221
}
224222
```
225223

@@ -251,14 +249,11 @@ try {
251249
$wc = New-Object System.Net.WebClient
252250
$tempFile = "c:\temp\MyDoc.doc"
253251
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc",$tempFile)
254-
}
255-
catch [System.Net.WebException],[System.IO.IOException] {
252+
} catch [System.Net.WebException],[System.IO.IOException] {
256253
"Unable to download MyDoc.doc from http://www.contoso.com."
257-
}
258-
catch {
254+
} catch {
259255
"An error occurred that could not be resolved."
260-
}
261-
finally {
256+
} finally {
262257
$wc.Dispose()
263258
if (Test-Path $tempPath) { Remove-item $tempFile }
264259
}

reference/7.4/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ block.
118118
PowerShell does not recognize "NonsenseString" as a cmdlet or other item.
119119
Running this script returns the following result:
120120

121-
```powershell
121+
```Output
122122
An error occurred.
123123
```
124124

@@ -133,16 +133,13 @@ two `catch` blocks:
133133

134134
```powershell
135135
try {
136-
$wc = New-Object System.Net.WebClient
137-
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
138-
}
139-
catch [System.Net.WebException],[System.IO.IOException] {
136+
$wc = New-Object System.Net.WebClient
137+
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
138+
} catch [System.Net.WebException],[System.IO.IOException] {
140139
"Unable to download MyDoc.doc from http://www.contoso.com."
141-
}
142-
catch {
140+
} catch {
143141
"An error occurred that could not be resolved."
144142
}
145-
146143
```
147144

148145
The first `catch` block handles errors of the **System.Net.WebException** and
@@ -156,8 +153,9 @@ from the specified class. The following example contains a `catch` block that
156153
catches a "Command Not Found" error:
157154

158155
```powershell
159-
catch [System.Management.Automation.CommandNotFoundException]
160-
{"Inherited Exception" }
156+
catch [System.Management.Automation.CommandNotFoundException] {
157+
"Inherited Exception"
158+
}
161159
```
162160

163161
The specified error type, **CommandNotFoundException**, inherits from the
@@ -197,8 +195,8 @@ also known as `$PSItem`. The object is of type **ErrorRecord**.
197195
```powershell
198196
try { NonsenseString }
199197
catch {
200-
Write-Host "An error occurred:"
201-
Write-Host $_
198+
Write-Host "An error occurred:"
199+
Write-Host $_
202200
}
203201
```
204202

@@ -218,8 +216,8 @@ change the script to the following:
218216
```powershell
219217
try { NonsenseString }
220218
catch {
221-
Write-Host "An error occurred:"
222-
Write-Host $_.ScriptStackTrace
219+
Write-Host "An error occurred:"
220+
Write-Host $_.ScriptStackTrace
223221
}
224222
```
225223

@@ -251,14 +249,11 @@ try {
251249
$wc = New-Object System.Net.WebClient
252250
$tempFile = "c:\temp\MyDoc.doc"
253251
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc",$tempFile)
254-
}
255-
catch [System.Net.WebException],[System.IO.IOException] {
252+
} catch [System.Net.WebException],[System.IO.IOException] {
256253
"Unable to download MyDoc.doc from http://www.contoso.com."
257-
}
258-
catch {
254+
} catch {
259255
"An error occurred that could not be resolved."
260-
}
261-
finally {
256+
} finally {
262257
$wc.Dispose()
263258
if (Test-Path $tempPath) { Remove-item $tempFile }
264259
}

reference/7.5/Microsoft.PowerShell.Core/About/about_Try_Catch_Finally.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ block.
118118
PowerShell does not recognize "NonsenseString" as a cmdlet or other item.
119119
Running this script returns the following result:
120120

121-
```powershell
121+
```Output
122122
An error occurred.
123123
```
124124

@@ -133,16 +133,13 @@ two `catch` blocks:
133133

134134
```powershell
135135
try {
136-
$wc = New-Object System.Net.WebClient
137-
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
138-
}
139-
catch [System.Net.WebException],[System.IO.IOException] {
136+
$wc = New-Object System.Net.WebClient
137+
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:\temp\MyDoc.doc")
138+
} catch [System.Net.WebException],[System.IO.IOException] {
140139
"Unable to download MyDoc.doc from http://www.contoso.com."
141-
}
142-
catch {
140+
} catch {
143141
"An error occurred that could not be resolved."
144142
}
145-
146143
```
147144

148145
The first `catch` block handles errors of the **System.Net.WebException** and
@@ -156,8 +153,9 @@ from the specified class. The following example contains a `catch` block that
156153
catches a "Command Not Found" error:
157154

158155
```powershell
159-
catch [System.Management.Automation.CommandNotFoundException]
160-
{"Inherited Exception" }
156+
catch [System.Management.Automation.CommandNotFoundException] {
157+
"Inherited Exception"
158+
}
161159
```
162160

163161
The specified error type, **CommandNotFoundException**, inherits from the
@@ -197,8 +195,8 @@ also known as `$PSItem`. The object is of type **ErrorRecord**.
197195
```powershell
198196
try { NonsenseString }
199197
catch {
200-
Write-Host "An error occurred:"
201-
Write-Host $_
198+
Write-Host "An error occurred:"
199+
Write-Host $_
202200
}
203201
```
204202

@@ -218,8 +216,8 @@ change the script to the following:
218216
```powershell
219217
try { NonsenseString }
220218
catch {
221-
Write-Host "An error occurred:"
222-
Write-Host $_.ScriptStackTrace
219+
Write-Host "An error occurred:"
220+
Write-Host $_.ScriptStackTrace
223221
}
224222
```
225223

@@ -251,14 +249,11 @@ try {
251249
$wc = New-Object System.Net.WebClient
252250
$tempFile = "c:\temp\MyDoc.doc"
253251
$wc.DownloadFile("http://www.contoso.com/MyDoc.doc",$tempFile)
254-
}
255-
catch [System.Net.WebException],[System.IO.IOException] {
252+
} catch [System.Net.WebException],[System.IO.IOException] {
256253
"Unable to download MyDoc.doc from http://www.contoso.com."
257-
}
258-
catch {
254+
} catch {
259255
"An error occurred that could not be resolved."
260-
}
261-
finally {
256+
} finally {
262257
$wc.Dispose()
263258
if (Test-Path $tempPath) { Remove-item $tempFile }
264259
}

0 commit comments

Comments
 (0)