eyre-rs / color-eyre

Custom hooks for colorful human oriented error reports via panics and the eyre crate
Other
958 stars 57 forks source link

Reverse order for stacktrace #154

Open kdheepak opened 1 month ago

kdheepak commented 1 month ago

Thanks for the amazing package!

I wanted to check if there was a way to reverse the stacktrace produced by color_eyre? If there isn't a way to reverse the stacktrace, I wanted to check if the authors would consider a PR to add an option to reverse the stacktrace (defaulting to the way it is right now).

For context:

For long stacktraces, it's nicer to have the most recent stack at the bottom of the terminal to avoid having to scroll up every time there's an error. This is particularly annoying when working in terminal environments when I don't have a mouse handy for scrolling or the terminal doesn't handle mouse scrolling well (remote machines) or when the scrollback history is limited.

Python prints stacktraces in reverse, and in Rust better-panic offers a setting to change the order: https://docs.rs/better-panic/latest/better_panic/struct.Settings.html#method.most_recent_first

I also looked at other languages but pretty much every language (Java, Go, Ruby, etc) seems to do stacktraces with the most recent at the top. When looking at other languages, I found this article that illustrates my pain point pretty well. I'm not sure I necessarily agree with the conclusion of the author, I'm sure there are good reasons for the status quo, but I agree with the idea that stacktraces should be reversed when printed to the terminal: http://yellerapp.com/posts/2015-01-22-upside-down-stacktraces.html

This has also been discussed on the rust issue tracker: https://github.com/rust-lang/rust/issues/38873 although no changes were made to support this feature.

ten3roberts commented 1 month ago

Hi, thanks for opening this issue.

I am definitely open to add that, and agree that it feels more "natural"

A PR would 100% be appreciate, but please open it in the main eyre repo, as this one has been merged into the monorepo

I do not have the "Archive" privileges, only a maintainer

kdheepak commented 1 month ago

Thanks for the information! I wasn't aware this repo wasn't the source code. I'll make a PR to the main eyre repo.