From b174416895ca6a7c8ae06a66d419c87ff2461316 Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Tue, 8 Mar 2016 14:14:25 +0800 Subject: [PATCH] Fixed: exception swallowing --- .../modules/extras/windows/win_file_version.ps1 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/extras/windows/win_file_version.ps1 b/lib/ansible/modules/extras/windows/win_file_version.ps1 index 4ee8c6e3f6..b9fa39c0dc 100644 --- a/lib/ansible/modules/extras/windows/win_file_version.ps1 +++ b/lib/ansible/modules/extras/windows/win_file_version.ps1 @@ -42,32 +42,34 @@ Else{ } 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){ $file_version = '' } - $product_version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).ProductVersion + $product_version = $_version_fields.ProductVersion If ($product_version -eq $null){ $product_version= '' } - $file_major_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileMajorPart + $file_major_part = $_version_fields.FileMajorPart If ($file_major_part -eq $null){ $file_major_part= '' } - $file_minor_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileMinorPart + $file_minor_part = $_version_fields.FileMinorPart If ($file_minor_part -eq $null){ $file_minor_part= '' } - $file_build_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FileBuildPart + $file_build_part = $_version_fields.FileBuildPart If ($file_build_part -eq $null){ $file_build_part = '' } - $file_private_part = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path).FilePrivatePart - If ($file_private_part -eq $null){ + $file_private_part = $_version_fields.FilePrivatePart + If ($file_private_part -eq $null) $file_private_part = '' } } Catch{ + Fail-Json $result "Error: $_.Exception.Message" } Set-Attr $result.win_file_version "path" $path.toString()