diff --git a/src/router.ps1 b/src/router.ps1 index b3139be..ed7aca7 100644 --- a/src/router.ps1 +++ b/src/router.ps1 @@ -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