diff --git a/Adb/Functions/Test-AdbItemValidation.ps1 b/Adb/Functions/Test-AdbItemValidation.ps1 index 4de3a55..d4c8056 100644 --- a/Adb/Functions/Test-AdbItemValidation.ps1 +++ b/Adb/Functions/Test-AdbItemValidation.ps1 @@ -67,17 +67,28 @@ function Test-AdbItemValidation } catch { - $errorMessage = $_.ErrorDetails.Message | ConvertFrom-Json | Select-Object -ExpandProperty 'error' - - if ([System.String]::IsNullOrEmpty($errorMessage)) + try { - $errorMessage = $_.ErrorDetails.Message - } + $errorMessage = $_.ErrorDetails.Message | ConvertFrom-Json | Select-Object -ExpandProperty 'error' - $result = [PSCustomObject] @{ - Result = $false - Message = $errorMessage - Violations = $errorMessage.Split(([System.String[]] ', '), [System.StringSplitOptions]::None) + if ([System.String]::IsNullOrEmpty($errorMessage)) + { + $errorMessage = $_.ErrorDetails.Message + } + + $result = [PSCustomObject] @{ + Result = $false + Message = $errorMessage + Violations = $errorMessage.Split(([System.String[]] ', '), [System.StringSplitOptions]::None) + } + } + catch + { + $result = [PSCustomObject] @{ + Result = $false + Message = "Internal Item Validation Error: $_" + Violations = "Internal Item Validation Error: $_" + } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bd7b6..a5c3c35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is mainly based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +* Fixed: If the validation parsing has an error, don't throw but return false + ## 1.4.0 - 2020-04-09 * Added: Command to add and remove templates from the adb item