Skip to content

Conversation

Graveflo
Copy link
Contributor

adds asyncTracebacks compile flag to stop asyncfutures module from overwriting user specified error messages

@Graveflo
Copy link
Contributor Author

Graveflo commented Jul 31, 2025

as a side note: it seems like the only utility in these "async tracebacks" is to condense the stack trace removing commonality from "reraised from" traces. It's not a bad idea to do that in general to make them easier to read, so maybe that is a better solution to injectStacktrace. There would probably need to be some kind of marker to signify that the stack trace includes part of the previous trace. like:

a/b.nim(47)
a/c.nim(30) <-- some marker here
a/d.nim(30)
[[reraised from:
...
a/e.nim(30)
]]

@arnetheduck
Copy link
Contributor

I think the fundamental design flaw here is that text-based stack traces are generated at all at the raise site - ie the natural thing to do here would have been to keep a chain of nested Exception instances, each of which contains a list of instruction pointers that can be translated to text on demand should they be asked for, formatting them at the point where they are consumed (ie printed to screen, string or log) instead of doing so up-front and clobbering the msg field.

This approach would also allow deduplicating them more productively, ie by filtering out any "common base" pointers.

@Graveflo
Copy link
Contributor Author

For these async trackbacks specifically, something like that was the first thing that I tried to do. I didn't want to add anything to FutureBase or recolor the final exception, and in the end it seemed impractical to re-use the current data structures for this. Maybe that is why it was done this way to begin with as a lazy hack. I didn't try too hard though because it's hard to justify the time investment when the end result is just slight convenience. So agreed. Either way, given the current behavior, I do wish to turn this off when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants