Skip to content

Attach stacktrace information to SomeException

Now (base 4.9.0.0) ErrorCall contain field for stacktrace information and error fills it.

If you add field for stacktrace information to SomeException

data SomeException where
    SomeExceptionWithLocation :: Exception e => String -> e -> SomeException

pattern SomeException :: () => Exception e => e -> SomeException
pattern SomeException err <- SomeExceptionWithLocation _ err where
  SomeException err = SomeExceptionWithLocation "" err

and will fills it in throw

throw :: (HasCallStack, Exception e) => e -> a
throw e = unsafeDupablePerformIO $ do
    stack <- currentCallStack
    raise# (CallStackException e $ if stack /= []
        then prettyCallStack ?callStack ++ "\n" ++ renderStack stack
        else prettyCallStack ?callStack)

it will be more useful for ghci users.

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information