Can I get detailed exception stacktrace in PowerShell?

前端 未结 12 1143
暗喜
暗喜 2020-12-02 12:23

Runing such script:

 1: function foo()
 2: {
 3:    bar
 4: }
 5: 
 6: function bar()
 7: {
 8:     throw \"test\"
 9: }
10: 
11: foo

I see

12条回答
  •  臣服心动
    2020-12-02 12:33

    Stumbled upon this looking for a built in solution. I am going with simple solution. Just add trace block before using any powershell. This will ensure a call stack is shown. Down side of this is the stack will be displayed before the error message.

    Trace {
       $_.ScriptStackTrace
    }
    

提交回复
热议问题