如何在Servant处理程序中未捕获的异常上打印堆栈跟踪?

问题描述

当我使用剖析信息构建应用程序时,未捕获的异常会导致将漂亮的堆栈跟踪信息打印到控制台。例如:

CallStack (from -prof):
  Redacted.Booking.API.Callback.Parse.parseFromEnv (src/Redacted/Booking/API/Callback/Parse.hs:(38,1)-(40,93))
  Main.main.readCallbackUrl (app/Main.hs:(51,5)-(54,77))
  Control.Exception.Lifted.finally.\ (Control/Exception/Lifted.hs:(426,22)-(427,47))
  Control.Monad.Trans.Control.liftBaseWith (Control/Monad/Trans/Control.hs:627:66-86)
  Control.Monad.Trans.Control.control (Control/Monad/Trans/Control.hs:751:1-39)
  Control.Exception.Lifted.finally (Control/Exception/Lifted.hs:(425,1)-(427,47))
  Control.Logging.withStderrLogging (Control/Logging.hs:(165,1)-(169,24))
  Redacted.Logging.withStderrLogging (src/Redacted/Logging.hs:(26,1)-(31,40))
  Main.main (app/Main.hs:(37,1)-(54,77))

但是,如果在Servant处理程序中发生未捕获的异常,则不会打印堆栈跟踪-仅显示异常,例如:

Prelude.maximum: empty list

我正在使用Stack进行构建,同时在我的stack.yaml中添加以下内容

build:
  library-profiling: true
  executable-profiling: true

如何为Servant处理程序中发生的未捕获异常打印堆栈跟踪?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)