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

Jail::expect_with/try_with do not allow returning non-Figment Error types #138

Open
detjensrobert opened this issue Mar 6, 2025 · 0 comments

Comments

@detjensrobert
Copy link

detjensrobert commented Mar 6, 2025

I am using Jails to set test config values and envvars for some tests, and the functions being tested all return a non-Figment Error type as a Result. The Jail body does not accept these errors as a valid return, and I have to either manually assert is_ok() or map the error into a String for every Result.

an example:

Image

Ideally, the Jail body should accept something like Box<dyn Error> so that any application errors can be handled by early-?.

    figment::Jail::expect_with(|jail| {
        // would be ideal, but doesnt work
        fallible_foo()?;

        // works but gross
       breakable_bar().map_err(|e| format!("{e:?}"))?;

        Ok(())
    });
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

1 participant