1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixed: exception swallowing

This commit is contained in:
Sam Liu 2016-03-08 14:14:25 +08:00 committed by Matt Clay
parent d5fe7633e2
commit b174416895

View file

@ -42,32 +42,34 @@ Else{
} }
Try { Try {
$file_version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileVersion $_version_fields = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path)
$file_version = $_version_fields.FileVersion
If ($file_version -eq $null){ If ($file_version -eq $null){
$file_version = '' $file_version = ''
} }
$product_version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).ProductVersion $product_version = $_version_fields.ProductVersion
If ($product_version -eq $null){ If ($product_version -eq $null){
$product_version= '' $product_version= ''
} }
$file_major_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileMajorPart $file_major_part = $_version_fields.FileMajorPart
If ($file_major_part -eq $null){ If ($file_major_part -eq $null){
$file_major_part= '' $file_major_part= ''
} }
$file_minor_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileMinorPart $file_minor_part = $_version_fields.FileMinorPart
If ($file_minor_part -eq $null){ If ($file_minor_part -eq $null){
$file_minor_part= '' $file_minor_part= ''
} }
$file_build_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileBuildPart $file_build_part = $_version_fields.FileBuildPart
If ($file_build_part -eq $null){ If ($file_build_part -eq $null){
$file_build_part = '' $file_build_part = ''
} }
$file_private_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FilePrivatePart $file_private_part = $_version_fields.FilePrivatePart
If ($file_private_part -eq $null){ If ($file_private_part -eq $null)
$file_private_part = '' $file_private_part = ''
} }
} }
Catch{ Catch{
Fail-Json $result "Error: $_.Exception.Message"
} }
Set-Attr $result.win_file_version "path" $path.toString() Set-Attr $result.win_file_version "path" $path.toString()