Skip to content

Commit 9ca1d83

Browse files
committed
Improve error message.
Issue #3
1 parent 4ca212b commit 9ca1d83

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/test_result.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::response::search_results::SearchResultsNewStyle;
33
use crate::test_case::TestCase;
44
use crate::timed_response::TimedResponse;
55
use crate::timed_search_results::TimedSearchResults;
6-
use anyhow::Result;
6+
use anyhow::{Context, Result};
77
use std::time::Duration;
88

99
#[derive(Clone, Debug, PartialEq)]
@@ -31,7 +31,8 @@ impl TestResult {
3131
let json = json?;
3232
match test_case.search_type() {
3333
None => todo!(),
34-
Some(search_type) => SearchResultsNewStyle::new(search_type, json.as_str()),
34+
Some(search_type) => SearchResultsNewStyle::new(search_type, json.as_str())
35+
.context("Could not extract search results from server response"),
3536
}
3637
}
3738
}
@@ -89,7 +90,10 @@ mod tests {
8990
let results =
9091
TestResult::new_style_results(&test_case, Ok(String::from("This is not JSON")))
9192
.unwrap_err();
92-
assert_eq!(results.to_string(), "expected value at line 1 column 1") // TODO: Improve error message.
93+
assert_eq!(
94+
results.to_string(),
95+
"Could not extract search results from server response"
96+
)
9397
}
9498

9599
fn ok_response() -> TimedResponse {

0 commit comments

Comments
 (0)