Private/Responses.ps1
function Show-PodeErrorPage { param( [Parameter()] [int] $Code, [Parameter()] [string] $Description, [Parameter()] $Exception, [Parameter()] [string] $ContentType ) # error page info $errorPage = Find-PodeErrorPage -Code $Code -ContentType $ContentType # if no page found, return if (Test-PodeIsEmpty $errorPage) { return } # if exception trace showing enabled then build the exception details object $ex = $null if (!(Test-PodeIsEmpty $Exception) -and $PodeContext.Server.Web.ErrorPages.ShowExceptions) { $ex = @{ Message = [System.Web.HttpUtility]::HtmlEncode($Exception.Exception.Message) StackTrace = [System.Web.HttpUtility]::HtmlEncode($Exception.ScriptStackTrace) Line = [System.Web.HttpUtility]::HtmlEncode($Exception.InvocationInfo.PositionMessage) Category = [System.Web.HttpUtility]::HtmlEncode($Exception.CategoryInfo.ToString()) } } # setup the data object for dynamic pages $data = @{ Url = [System.Web.HttpUtility]::HtmlEncode((Get-PodeUrl)) Status = @{ Code = $Code Description = $Description } Exception = $ex ContentType = $errorPage.ContentType } # write the error page to the stream Write-PodeFileResponse -Path $errorPage.Path -Data $data -ContentType $errorPage.ContentType } |