Fix panic in load_data(url=%s)
If there is no response from the server, `load_data` would panic
with: `response status`.
This patch removes the `expect` in favor of an error message that we
couldn't get a response from the server for a given url.
@@ -210,11 +210,10 @@ impl TeraFn for LoadData {
.send()
.and_then(|res| res.error_for_status())
.map_err(|e| {
- format!(
- "Failed to request {}: {}",
- url,
- e.status().expect("response status")
- )
+ match e.status() {
+ Some(status) => format!("Failed to request {}: {}", url, status),
+ None => format!("Could not get response status for url: {}", url),
+ }
})?;
response
.text()
