Skip to content

Commit b2ca17f

Browse files
committed
Improve error handing in client example
1 parent 3c0b218 commit b2ca17f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ net2 = "0.2"
2626
rotor-test = "0.1.0"
2727
url = "0.5.7"
2828
argparse = "0.2.1"
29+
env_logger = "0.3.2"
2930

3031
[lib]
3132
name = "rotor_http"

examples/client.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ extern crate rotor;
22
extern crate rotor_http;
33
extern crate argparse;
44
extern crate url;
5+
extern crate env_logger;
56

67

78
use std::io::{stdout, stderr};
@@ -111,10 +112,16 @@ impl Requester for Req {
111112
{
112113
unimplemented!();
113114
}
115+
fn bad_response(self, _scope: &mut Scope<Context>)
116+
{
117+
writeln!(&mut stderr(), "----- Bad response -----").ok();
118+
exit(1);
119+
}
114120
}
115121

116122

117123
fn main() {
124+
env_logger::init().unwrap();
118125
let mut url = Url::parse(
119126
"http://info.cern.ch/hypertext/WWW/TheProject.html").unwrap();
120127
{

0 commit comments

Comments
 (0)