Skip to content

Commit e00fd9b

Browse files
committed
fix error and add error handle for example
1 parent 67f7ba0 commit e00fd9b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

examples/ipinfo.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bevy_http_client::prelude::*;
44
fn main() {
55
App::new()
66
.add_plugins((MinimalPlugins, HttpClientPlugin))
7-
.add_systems(Update, handle_response)
7+
.add_systems(Update, (handle_response, handle_error))
88
.add_systems(
99
Update,
1010
send_request.run_if(on_timer(std::time::Duration::from_secs(1))),
@@ -22,3 +22,9 @@ fn handle_response(mut ev_resp: EventReader<HttpResponse>) {
2222
println!("response: {:?}", response.text());
2323
}
2424
}
25+
26+
fn handle_error(mut ev_error: EventReader<HttpResponseError>) {
27+
for error in ev_error.read() {
28+
println!("Error retrieving IP: {}", error.err);
29+
}
30+
}

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ fn handle_request(
516516
world.entity_mut(entity).despawn_recursive();
517517
}
518518
});
519-
println!("commands_queue: {:?}", command_queue);
519+
520520
tx.send(command_queue).unwrap();
521521
})
522522
.detach();

src/typed.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ where
110110
inner: T,
111111
}
112112

113-
impl<T> TypedResponse<T> {
114-
/// Returns a reference to the inner data contained in the HTTP response.
115-
pub fn get_inner(&self) -> &T {
116-
&self.inner
117-
}
118-
113+
impl<T: for<'a> serde::Deserialize<'a>> TypedResponse<T> {
119114
/// Consumes the HTTP response and returns the inner data.
120115
pub fn into_inner(self) -> T {
121116
self.inner

0 commit comments

Comments
 (0)