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

Adding context to glob! on panic #399

Open
nyurik opened this issue Aug 18, 2023 · 2 comments
Open

Adding context to glob! on panic #399

nyurik opened this issue Aug 18, 2023 · 2 comments

Comments

@nyurik
Copy link

nyurik commented Aug 18, 2023

In case my code panics in this common pattern, it is somewhat difficult to figure out which original file has caused the failure. Would it be possible for glob! to use catch_unwind and report the file being processed?

glob!("../tests/fixtures", "**/*.txt", |file| {
    // this panic is deep inside the code,
    // without any knowledge of the current file
    panic!("something panicked"); 
});

Expected output

---- my_test stdout ----
while processing `some_path/my_input_file_discovered_by_glob.txt`:
thread 'my_test' panicked at <some_file>:
My error message
@max-sixty
Copy link
Sponsor Contributor

Slightly tangential, but we use description=> to add context to the errors within a glob!:

https://github.com/PRQL/prql/blob/c3ab63acdbd0729f73a18aa420216bc91cc7d2d1/crates/prql-compiler/tests/integration/main.rs#L345-L349

(giving more context automatically sounds like a good idea too though...)

@mitsuhiko
Copy link
Owner

Maybe there could be a flag that controls catching of panics. I think the issue is that the rust testing infrastructure is already pretty brittle as it stands and catching down panics might be a bit too magic?

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

No branches or pull requests

3 participants