mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Merge pull request #447 from Icinga:feature/surpress_errors_on_new_progress_status
Feature: Supresses error messages on progress status Adds `-PrintErrors` to `New-IcingaProgressStatus`, surpressing all errors by default, allowing to add this for testing internally.
This commit is contained in:
commit
d525b22cc1
1 changed files with 10 additions and 9 deletions
|
|
@ -1,26 +1,27 @@
|
||||||
function New-IcingaProgressStatus()
|
function New-IcingaProgressStatus()
|
||||||
{
|
{
|
||||||
param (
|
param (
|
||||||
[string]$Name = '',
|
[string]$Name = '',
|
||||||
[int]$CurrentValue = 0,
|
[int]$CurrentValue = 0,
|
||||||
[int]$MaxValue = 1,
|
[int]$MaxValue = 1,
|
||||||
[string]$Message = 'Processing Icinga for Windows',
|
[string]$Message = 'Processing Icinga for Windows',
|
||||||
[string]$Status = '{0}% Complete',
|
[string]$Status = '{0}% Complete',
|
||||||
[switch]$Details = $FALSE
|
[switch]$Details = $FALSE,
|
||||||
|
[switch]$PrintErrors = $FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($Name)) {
|
if ([string]::IsNullOrEmpty($Name)) {
|
||||||
Write-IcingaConsoleError -Message 'Failed to create new progress status. You have to specify a name.';
|
Write-IcingaConsoleError -Message 'Failed to create new progress status. You have to specify a name.' -DropMessage:$(-Not $PrintErrors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($MaxValue -le 0) {
|
if ($MaxValue -le 0) {
|
||||||
Write-IcingaConsoleError -Message 'Failed to create new progress status. The maximum value has to be larger than 0.';
|
Write-IcingaConsoleError -Message 'Failed to create new progress status. The maximum value has to be larger than 0.' -DropMessage:$(-Not $PrintErrors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Global:Icinga.Private.ProgressStatus.ContainsKey($Name)) {
|
if ($Global:Icinga.Private.ProgressStatus.ContainsKey($Name)) {
|
||||||
Write-IcingaConsoleError -Message 'Failed to create new progress status. A progress status with this name is already active. Use "Complete-IcingaProgressStatus" to remove it.';
|
Write-IcingaConsoleError -Message 'Failed to create new progress status. A progress status with this name is already active. Use "Complete-IcingaProgressStatus" to remove it.' -DropMessage:$(-Not $PrintErrors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue