Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant