Skip to content

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

@chshersh

Description

@chshersh

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions