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

Attach Report's to an error via Section::error() #122

Open
SergeyKasmy opened this issue Feb 28, 2023 · 0 comments
Open

Attach Report's to an error via Section::error() #122

SergeyKasmy opened this issue Feb 28, 2023 · 0 comments

Comments

@SergeyKasmy
Copy link

Currently it is not possible to attach reports to an error via the section trait as the Section::error() method takes a type that must implement Error which Report does not. Since it's not possible to implement Error for Report, are there any plans of adding Section::report_error() or something similar to support that use-case?

For example, this doesn't work:

let results: Vec<Result<(), Report>> = job();
let errors = results.into_iter().filter_map(|res| match res {
		Ok(()) => None,
		Err(e) => Some(e),
	}).collect::<Vec<Report>>();

if errors.is_empty() {
	return Ok(());
}

let error = errors.into_iter().fold(
	eyre!("{} jobs have finished with an error", errors.len()),
	|acc, err| acc.error(err),
);

Err(error)
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