@@ -230,33 +230,40 @@ function WebScrapping {
230
230
231
231
$GraphDocsUrl = " https://raw.githubusercontent.com/microsoftgraph/microsoft-graph-docs-contrib/main/api-reference/$GraphProfile /api/$LastExternalDocUrlPathSegmentWithoutQueryParam .md"
232
232
$MsprodContent = " "
233
- Write-Host " Downloading $GraphDocsUrl "
234
- ($readStream , $HttpWebResponse ) = FetchStream - GraphDocsUrl $GraphDocsUrl
233
+ try {
234
+ ($readStream , $HttpWebResponse ) = FetchStream - GraphDocsUrl $GraphDocsUrl
235
235
236
- while (-not $readStream.EndOfStream ) {
237
- $Line = $readStream.ReadLine ()
238
- if ($Line -match " ms.prod" ) {
239
- $MsprodContent = $Line
240
- }
241
- }
242
- $HttpWebResponse.Close ()
243
- $readStream.Close ()
244
-
245
- if ([string ]::IsNullOrEmpty($MsprodContent )) {
246
- Write-Host " Ms Prod content is null or empty"
247
- }
248
- else {
249
- # Remove single and double qoutes from ms prod
250
- $MsprodContent = $MsprodContent.Replace (" `" " , " " )
251
- $MsprodContent = $MsprodContent.Replace (" '" , " " )
252
- $MetaDataText = " schema: 2.0.0`r`n $MsprodContent "
253
- (Get-Content $File ) |
254
- Foreach-Object {
255
- if ($_ -notcontains $MetaDataText ) {
256
- $_ -replace ' schema: 2.0.0' , $MetaDataText
236
+ while (-not $readStream.EndOfStream ) {
237
+ $Line = $readStream.ReadLine ()
238
+ if ($Line -match " ms.prod" ) {
239
+ $MsprodContent = $Line
257
240
}
258
- } |
259
- Out-File $File
241
+ }
242
+ $HttpWebResponse.Close ()
243
+ $readStream.Close ()
244
+
245
+ if ([string ]::IsNullOrEmpty($MsprodContent )) {
246
+ Write-Host " Ms Prod content is null or empty"
247
+ }
248
+ else {
249
+ # Remove single and double qoutes from ms prod
250
+ $MsprodContent = $MsprodContent.Replace (" `" " , " " )
251
+ $MsprodContent = $MsprodContent.Replace (" '" , " " )
252
+ $MetaDataText = " schema: 2.0.0`r`n $MsprodContent "
253
+ (Get-Content $File ) |
254
+ Foreach-Object {
255
+ if ($_ -notcontains $MetaDataText ) {
256
+ $_ -replace ' schema: 2.0.0' , $MetaDataText
257
+ }
258
+ } |
259
+ Out-File $File
260
+ }
261
+ }catch {
262
+ Write-Host " `n Error Message: " $_.Exception.Message
263
+ Write-Host " `n Error in Line: " $_.InvocationInfo.Line
264
+ Write-Host " `n Error in Line Number: " $_.InvocationInfo.ScriptLineNumber
265
+ Write-Host " `n Error Item Name: " $_.Exception.ItemName
266
+ Write-Host " `n Raw docs url : " $GraphDocsUrl
260
267
}
261
268
}
262
269
0 commit comments