BuildError.fromMultiple constructor
BuildError.fromMultiple(
- Iterable<
BuildError> errors, [ - String header = 'Multiple errors occurred'
Collapse multiple errors
into a single error.
This constructor is suitable when collecting lazy errors from another part of the compilation process (such as parsing HTML or CSS) to turn into a single but immediate error:
void example(ExternalParser parser) {
final errors = parser.getErrors();
if (errors.isNotEmpty) {
// Impossible to continue
throw BuildError.fromMultiple(errors, 'Errors occured parsing');
}
}
When defining a custom header
, it should not end with :
.
Implementation
factory BuildError.fromMultiple(
Iterable<BuildError> errors, [
String header = 'Multiple errors occurred',
]) =>
_MultipleBuildError(errors.toList(), header);