Skip to content

Not working for exception thrown by library function without HasCallStack #13

Open

Description

@yaitskov

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.

Activity

  1. changed the title [-]Not working for IO function[/-] [+]Not working for exception thrown by function without HasCallStack[/+] on Dec 13, 2021
  2. yaitskov commented on Dec 13, 2021

    @yaitskov
    Author

    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"
    
  3. changed the title [-]Not working for exception thrown by function without HasCallStack[/-] [+]Not working for exception thrown by library function without HasCallStack[/+] on Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions