Public/Write-GitHubError.ps1

function Write-GitHubError {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [AllowEmptyString()]
        [string] $Message,

        [string] $Title,

        [string] $File,

        [ValidateRange(1, [int]::MaxValue)]
        [Nullable[int]] $Line,

        [ValidateRange(1, [int]::MaxValue)]
        [Nullable[int]] $EndLine,

        [ValidateRange(1, [int]::MaxValue)]
        [Nullable[int]] $Column,

        [ValidateRange(1, [int]::MaxValue)]
        [Nullable[int]] $EndColumn
    )

    $properties = [ordered]@{}

    foreach ($parameterName in 'Title', 'File', 'Line', 'EndLine', 'Column', 'EndColumn') {
        if (-not $PSBoundParameters.ContainsKey($parameterName)) {
            continue
        }

        switch ($parameterName) {
            'Title' { $properties.title = $Title }
            'File' { $properties.file = $File }
            'Line' { $properties.line = $Line }
            'EndLine' { $properties.endLine = $EndLine }
            'Column' { $properties.col = $Column }
            'EndColumn' { $properties.endColumn = $EndColumn }
        }
    }

    Write-GitHubWorkflowCommandInternal -Command 'error' -Message $Message -Properties $properties
}