Skip to content

Commit d4ce8a5

Browse files
committed
rewrite error out standard
1 parent 211a881 commit d4ce8a5

File tree

2 files changed

+18
-44
lines changed

2 files changed

+18
-44
lines changed

eng/scripts/Invoke-GenerateAndBuildV2.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ if ($relatedTypeSpecProjectFolder) {
137137
Invoke-Expression $tspclientCommand
138138
if ($LASTEXITCODE) {
139139
# If Process script call fails, then return with failure to CI and don't need to call GeneratePackage
140-
Write-Error "[ERROR] Failed to generate typespec project:$typespecFolder. Exit code: $LASTEXITCODE."
141-
Write-Error "[ERROR] Please review the detail errors for potential fixes."
142-
Write-Error "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
140+
Write-Host "[ERROR] Failed to generate typespec project:$typespecFolder. Exit code: $LASTEXITCODE. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
143141
$generatedSDKPackages.Add(@{
144142
result = "failed";
145143
path=@("");

eng/scripts/automation/GenerateAndBuildLib.ps1

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function Get-SwaggerInfo()
4545
}
4646
catch
4747
{
48-
Write-Error "Error parsing swagger info"
49-
Write-Error $_
48+
Write-Host "[ERROR] Error parsing swagger info: $_"
5049
}
5150
Write-Host "Cannot find swagger info"
5251
exit 1
@@ -263,8 +262,7 @@ function Update-DataPlanePackageFolder() {
263262
CreateOrUpdateAutorestConfigFile -autorestFilePath $file -namespace $namespace -inputfile "$inputfile" -readme "$readme" -autorestConfigYaml "$autorestConfigYaml"
264263
Update-CIYmlFile -ciFilePath $ciymlFilePath -artifact $namespace
265264
} else {
266-
Write-Error "Project directory doesn't exist. It is a new .NET SDK."
267-
Write-Error "We will not support onboard a new SDK from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
265+
Write-Host "[ERROR] Project directory doesn't exist. It is a new .NET SDK. We will not support onboard a new SDK from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
268266
exit 1
269267
}
270268

@@ -312,8 +310,7 @@ function Update-MgmtPackageFolder() {
312310
$mgmtPackageName = $folderinfo.Name
313311
$projectFolder = "$sdkPath/sdk/$packageName/$mgmtPackageName"
314312
} else {
315-
Write-Error "Project directory doesn't exist. It is a new .NET SDK."
316-
Write-Error "We will not support onboard a new service SDK from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
313+
Write-Host "[ERROR] Project directory doesn't exist. It is a new .NET SDK. We will not support onboard a new service SDK from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
317314
exit 1
318315
}
319316

@@ -561,7 +558,7 @@ function Invoke-GenerateAndBuildSDK () {
561558
Write-Host "service:$service, serviceType:$serviceType"
562559

563560
if (!$readmeFile.StartsWith("http") -And !(Test-Path -Path $readmeFile)) {
564-
Write-Error "[ERROR] readme file '$readmeFile' does not exist. Please provide a valid readme file path."
561+
Write-Host "[ERROR] readme file '$readmeFile' does not exist. Please provide a valid readme file path."
565562
exit 1
566563
}
567564

@@ -578,18 +575,15 @@ function Invoke-GenerateAndBuildSDK () {
578575
if (Test-Path -Path $projectFolder) {
579576
Update-MgmtPackageFolder -service $service -packageName $package -sdkPath $sdkRootPath -commitid $commitid -readme $readmeFile -outputJsonFile $newpackageoutput
580577
if ( !$?) {
581-
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,package:$package,"
582-
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile.exit code: $?."
583-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
584-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
578+
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,package:$package, sdkPath:$sdkRootPath,readme:$readmeFile.exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
585579
exit 1
586580
}
587581
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
588582
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
589583
Remove-Item $newPackageOutput
590584
} else {
591585
Write-Host "Path doesn't exist. create template."
592-
Write-Error "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
586+
Write-Host "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
593587
exit 1
594588
}
595589
} else {
@@ -619,18 +613,15 @@ function Invoke-GenerateAndBuildSDK () {
619613
Write-Host "Path exists!"
620614
Update-DataPlanePackageFolder -service $service -namespace $namespace -sdkPath $sdkRootPath -readme $readmeFile -autorestConfigYaml "$autorestConfigYaml" -outputJsonFile $newpackageoutput
621615
if ( !$? ) {
622-
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$namespace,"
623-
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile,autorestConfigYaml:$autorestConfigYaml.exit code: $?."
624-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
625-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
616+
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$namespace, sdkPath:$sdkRootPath,readme:$readmeFile,autorestConfigYaml:$autorestConfigYaml.exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
626617
exit 1
627618
}
628619
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
629620
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
630621
Remove-Item $newPackageOutput
631622
} else {
632623
Write-Host "SDK project folder doesn't exist."
633-
Write-Error "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
624+
Write-Host "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
634625
exit 1
635626
}
636627
} else {
@@ -656,18 +647,15 @@ function Invoke-GenerateAndBuildSDK () {
656647
Write-Host "Path exists!"
657648
Update-DataPlanePackageFolder -service $service -namespace $folder -sdkPath $sdkRootPath -readme $readmeFile -outputJsonFile $newpackageoutput
658649
if ( !$? ) {
659-
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$folder,"
660-
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile. exit code: $?."
661-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
662-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
650+
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$folder, sdkPath:$sdkRootPath,readme:$readmeFile. exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
663651
exit 1
664652
}
665653
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
666654
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
667655
Remove-Item $newPackageOutput
668656
} else {
669657
Write-Host "SDK project folder doesn't exist."
670-
Write-Error "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
658+
Write-Host "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
671659
exit 1
672660
}
673661
}
@@ -725,9 +713,7 @@ function GeneratePackage()
725713
dotnet build /t:GenerateCode $srcPath /p:SpecRepoRoot=$specRepoRoot
726714
}
727715
if ( !$?) {
728-
Write-Host "[ERROR] Failed to generate sdk for package:$packageName. Exit code: $?."
729-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
730-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
716+
Write-Host "[ERROR] Failed to generate sdk for package:$packageName. Exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
731717
$result = "failed"
732718
$isGenerateSuccess = $false
733719
}
@@ -742,9 +728,7 @@ function GeneratePackage()
742728
Write-Host "Start to build sdk project: $srcPath"
743729
dotnet build $srcPath /p:RunApiCompat=$false
744730
if ( !$?) {
745-
Write-Host "[ERROR] Failed to build the sdk project: $packageName for service: $service. Exit code: $?."
746-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
747-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
731+
Write-Host "[ERROR] Failed to build the sdk project: $packageName for service: $service. Exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
748732
$result = "failed"
749733
} else {
750734
# Build the whole solution and generate artifacts if the project build successfully
@@ -753,18 +737,14 @@ function GeneratePackage()
753737
$serviceProjFilePath = Join-Path $sdkRootPath 'eng' 'service.proj'
754738
dotnet build /p:Scope=$service /p:Project=$packageName /p:RunApiCompat=$false $serviceProjFilePath
755739
if ( !$? ) {
756-
Write-Host "[ERROR] Failed to build sdk solution:$packageName. Exit code: $?."
757-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
758-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
740+
Write-Host "[ERROR] Failed to build sdk solution:$packageName. Exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
759741
$result = "failed"
760742
}
761743
# pack
762744
Write-Host "Start to pack sdk"
763745
dotnet pack $srcPath /p:RunApiCompat=$false
764746
if ( !$? ) {
765-
Write-Host "[ERROR] Failed to pack the sdk package: $packageName for service: $service. Exit code: $?."
766-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
767-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
747+
Write-Host "[ERROR] Failed to pack the sdk package: $packageName for service: $service. Exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
768748
$result = "failed"
769749
} else {
770750
# artifacts
@@ -778,18 +758,15 @@ function GeneratePackage()
778758
# check the artifact in Release folder
779759
$artifactsPath = (Join-Path "artifacts" "packages" "Release" $packageName)
780760
if (-not (Test-Path $artifactsPath)) {
781-
Write-Host "[ERROR] Artifact folder not found for $artifactsPath."
782-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
783-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
761+
Write-Host "[ERROR] Artifact folder not found for $artifactsPath. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
784762
}
785763
else {
786764
$artifacts += Get-ChildItem $artifactsPath -Filter *.nupkg -exclude *.symbols.nupkg -Recurse | Select-Object -ExpandProperty FullName | Resolve-Path -Relative
787765
}
788766
}
789767
$apiViewArtifact = ""
790768
if ( $artifacts.count -eq 0) {
791-
Write-Host "[ERROR] Failed to generate sdk artifact. Please review the detail errors for potential fixes."
792-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
769+
Write-Host "[ERROR] Failed to generate sdk artifact. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
793770
} else {
794771
$apiViewArtifact = $artifacts[0]
795772
}
@@ -808,8 +785,7 @@ function GeneratePackage()
808785
Write-Host "Start to export api for $service"
809786
& $sdkRootPath/eng/scripts/Export-API.ps1 $service
810787
if ( !$? ) {
811-
Write-Host "[ERROR] Failed to export api for sdk. exit code: $?. Please review the detail errors for potential fixes."
812-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
788+
Write-Host "[ERROR] Failed to export api for sdk. exit code: $?. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
813789
$result = "failed"
814790
}
815791
# breaking change validation

0 commit comments

Comments
 (0)