MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / collect_all_errors

Method collect_all_errors

crates/data-structures/src/error_stream.rs:377–398  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

375 type Error = E;
376
377 fn collect_all_errors<Collection: FromIterator<Self::Item>>(self) -> Result<Collection, ErrorStream<Self::Error>> {
378 // not in a valid state: contains no errors!
379 let mut all_errors = ErrorStream(Default::default());
380
381 let collection = self
382 .filter_map(|result| match result {
383 Ok(value) => Some(value),
384 Err(errors) => {
385 all_errors.extend(errors);
386 None
387 }
388 })
389 .collect::<Collection>();
390
391 if all_errors.0.is_empty() {
392 // invalid state is not returned.
393 Ok(collection)
394 } else {
395 // not empty, so we're good to return it.
396 Err(all_errors)
397 }
398 }
399}
400
401/// Helper macro to match against an error stream, expecting a specific error.

Callers 15

auto_migrate_viewsFunction · 0.80
auto_migrate_tablesFunction · 0.80
auto_migrate_indexesFunction · 0.80
auto_migrate_sequencesFunction · 0.80
auto_migrate_constraintsFunction · 0.80
try_newMethod · 0.80
add_definitionMethod · 0.80
validateFunction · 0.80
validate_table_defMethod · 0.80
validate_view_defMethod · 0.80
params_for_generateMethod · 0.80
validate_col_idsMethod · 0.80

Calls 5

ErrorStreamClass · 0.85
OkFunction · 0.50
ErrFunction · 0.50
extendMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected