Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ADR-10: Add proposal ADR for addressing lack of stack-traces in
cardano-api
#65New 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
base: main
Are you sure you want to change the base?
ADR-10: Add proposal ADR for addressing lack of stack-traces in
cardano-api
#65Changes from all commits
7edd91a
5582a19
b3676b9
989c8fc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the following:
We modify the existing
Error
class and wrap our errore
withWithCallStack
. Each error has a callstack included with the original pretty printing functionality. No need to introduce additional type classes and/or methods to capture the notion of a callstack.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good point that we don't need the classes, we could just use
WithCallStack
always. But:prettyError
toprettyErrorWithoutCallStack
and creating a method outside of the class that has the signatureprettyError :: Error e => WithCallStack e -> Doc ann
that usesprettyErrorWithoutCallStack
and appends the stacktrace.cause
field inWithCallStack
. But we have to make sure that the field incause
is an errorWithCallStack
and that is were theGADT
comes in.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not forced to render the
CallStack
if you don't want to in a givenError
instance.What about
data WithCallStack e = WithCallStack e (Last CallStack)
? We only care about the innermost callstack right? We can recurse andmappend
onLast CallStack
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still decide to not print it by calling
prettyErrorWithoutCallStack
instead ofprettyError
(which is probably the time where we want to make the choice anyway). Right?But also:
Error
.So, we could have
WitCallStack e1 c1 <> WitCallStack e2 c2 = WitCallStack (e1 $ e2) (c1 <> c2)
.Nice, I think it may work.
That is definitely the most important one. It is not always where the issue is, so it can make sense to see the stacktrace of the other errors too. Also, if the stack of the innermost error was long enough, then we wouldn't need anything else, because it includes callers, (but it probably isn't long enough all the time, especially because in Haskell functions are recursive). On the other hand, having several stacktraces clutters the error output a lot, so it may be a good compromise to just have the innermost.