Skip to content

Commit

Permalink
Return error from check_and_expect_one_error
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Feb 28, 2024
1 parent d26a255 commit cdc0ef7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/fj-core/src/validation/validation_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ pub trait ValidationCheck<T> {
///
/// This method is designed for convenience over flexibility (it is intended
/// for use in unit tests), and thus always uses the default configuration.
fn check_and_expect_one_error(&self)
fn check_and_expect_one_error(&self) -> T
where
T: Display,
{
let config = ValidationConfig::default();
let mut errors = self.check(&config).peekable();

errors
let err = errors
.next()
.expect("Expected one validation error; none found");

Expand All @@ -49,5 +49,7 @@ pub trait ValidationCheck<T> {

panic!("Expected only one validation error")
}

err
}
}

0 comments on commit cdc0ef7

Please sign in to comment.