< Summary - Kestrun — Combined Coverage

Information
Class: Private.Logging.Write-KrError
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Logging/Write-KrError.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 32
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 01/17/2026 - 04:33:35 Line coverage: 0% (0/5) Total lines: 32 Tag: Kestrun/Kestrun@aca34ea8d284564e2f9f6616dc937668dce926ba

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Logging/Write-KrError.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Logs an error message and optionally stops the Kestrun server.
 4.DESCRIPTION
 5    This function logs an error message using the Kestrun logging framework. If the Terminate switch is specified, it wi
 6.PARAMETER FunctionName
 7    The name of the function or cmdlet where the error occurred. Defaults to the current invocation name.
 8.PARAMETER ErrorMessage
 9    The error message to log.
 10.PARAMETER Terminate
 11    If specified, the function will stop the Kestrun server after logging the error.
 12.EXAMPLE
 13    Write-KrError -FunctionName 'Start-KrServer' -ErrorMessage 'Failed to start the server.' -Terminate
 14    This example logs an error message indicating that the server failed to start and then stops the Kestrun server.
 15.NOTES
 16    This function is intended for internal use within the Kestrun framework.
 17#>
 18function Write-KrError {
 19    param (
 20        [string]$FunctionName = $PSCmdlet.MyInvocation.InvocationName,
 21        [string]$ErrorMessage,
 22        [switch]$Terminate
 23    )
 024    if (Test-KrLogger) {
 025        Write-KrLog -Level Error -Message '{function}: {message}' -Values $FunctionName, $ErrorMessage
 26    } else {
 027        Write-Warning -Message "$($FunctionName): $ErrorMessage"
 28    }
 029    if ($Terminate) {
 030        Stop-KrServer -NoWait
 31    }
 32}

Methods/Properties

Write-KrError()