haskell-stack-trace-plugin
haskell-stack-trace-plugin copied to clipboard
Not working for exception thrown by library function without HasCallStack
stack new trace
app/Main.hs:
module Main where
-- import GHC.Stack
import System.Directory
import Data.Maybe (fromJust)
main :: IO ()
main = do
myDo "/z"
print f1
myDo x = do
getDirectoryContents x
stack.yaml:
extra-deps:
- haskell-stack-trace-plugin-0.1.3.0@sha256:b7f05707849dda721ed466df769ca9a3fb41de996c9cea1e568af85687489362,2121
package.yaml:
dependencies:
- base >= 4.7 && < 5
- directory
- haskell-stack-trace-plugin >= 0.1.3.0
executables:
stacktrace-plugin-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -fplugin=StackTrace.Plugin
- -threaded
- -rtsopts
- -with-rtsopts=-N
stack run ... Installing executable stacktrace-plugin-exe in /home/dan/demo/haskell/cabal/stacktrace-plugin/.stack-work/install/x86_64-linux-tinfo6/a312ec7a31d449d77cf93f7d5c4fe35cdb919b67bfa2faa8f121cda8cb898c28/8.10.7/bin Registering library for stacktrace-plugin-0.1.0.0.. stacktrace-plugin-exe: /z: getDirectoryContents:openDirStream: does not exist (No such file or directory)
No stack trace - just regular exception message in console. Running the demo with lazy functions is working for the same configuration.
The problem is about building dependencies with this plugin too. Same for head []
.
I would replace problematic base functions such as head with tracing wrappers:
traceableHead :: HasStackTrace => [a] -> a
traceableHead l@(a:_) = Prelude.head l
traceableHead _ = error $ "head of empty list"