Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] How to format multiple stack traces? #23

Open
chshersh opened this issue Sep 25, 2019 · 0 comments
Open

[RFC] How to format multiple stack traces? #23

chshersh opened this issue Sep 25, 2019 · 0 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@chshersh
Copy link
Contributor

Currently we store only the last position of source code in error:

data ErrorWithSource err = ErrorWithSource
    { errorWithSourceCallStack :: !SourcePosition
    , errorWithSourceType      :: !err
    } deriving stock (Show, Eq, Functor)

This approach has problems that if we have helpers to throw errors, we won't see useful errors messages, unless we wrap those helpers explicitly in withFrozenCallStack. It's quite easy to forget to wrap. Morever, last position might not always be helpful. So I propose to change the data type to the following:

data ErrorWithSource err = ErrorWithSource
    { errorWithSourceCallStack :: !CallStack
    , errorWithSourceType      :: !err
    } deriving stock (Show, Eq, Functor)

And change formatting function:

toSourcePosition :: CallStack -> [SourcePosition]

And ideally it would be nice to pretty-print this list... What are your ideas? Single source postion is formatted like this:

CakeSlayer.Error.foo#42

How would you format multiple errors?

@chshersh chshersh added enhancement New feature or request question Further information is requested labels Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant