Update src/router.ps1

This commit is contained in:
2026-01-25 00:02:36 -05:00
parent c100bd618c
commit fdf7ab0a76

View File

@@ -95,7 +95,9 @@ function Dispatch-Request {
# Always return something so clients don't hang
try {
$Context.Response.StatusCode = 500
$msg = "Dispatch error: $($_.Exception.Message)"
$pos = if ($_.InvocationInfo) { $_.InvocationInfo.PositionMessage } else { "" }
$stk = if ($_.ScriptStackTrace) { $_.ScriptStackTrace } else { "" }
$msg = "Dispatch error: $($_.Exception.Message)`n$pos`n$stk"
$bytes = [Text.Encoding]::UTF8.GetBytes($msg)
$Context.Response.ContentType = 'text/plain; charset=utf-8'
$Context.Response.ContentLength64 = $bytes.Length