diff --git a/examples/client.rs b/examples/client.rs index 83899a7..892a21b 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -58,7 +58,7 @@ fn main() { ]; let matches = match getopts(args_string.tail(), opts) { Ok(m) => { m } - Err(f) => { fail!("{}", f) } + Err(f) => { panic!("{}", f) } }; if matches.opt_present("h") { print_usage(description, opts); diff --git a/src/client/mod.rs b/src/client/mod.rs index 97931c8..d43d99d 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -79,13 +79,13 @@ impl Client { pub fn connect(&mut self) -> Result { // connect should not be called when the client is already connected if !self.stream.is_none() { - fail!("The connection is already established"); + panic!("The connection is already established"); } // Try to connect self.stream = match Connecter::connect(self.host.clone().as_slice(), self.port) { Ok(stream) => Some(stream), - Err(..) => fail!("Cannot connect to the server") + Err(..) => panic!("Cannot connect to the server") }; // Log the connection @@ -102,7 +102,7 @@ impl Client { Err(response) } }, - None => fail!("No banner on {}", self.host) + None => panic!("No banner on {}", self.host) } } @@ -114,7 +114,7 @@ impl Client { match self.connect() { Ok(_) => {}, - Err(response) => fail!("Cannot connect to {:s}:{:u}. Server says: {}", + Err(response) => panic!("Cannot connect to {:s}:{:u}. Server says: {}", self.host, self.port, response ) @@ -180,7 +180,7 @@ impl Client { // TODO : ensure this is an ASCII string fn send_command(&mut self, command: Command) -> Response { if !self.state.is_command_possible(command.clone()) { - fail!("Bad command sequence"); + panic!("Bad command sequence"); } self.send_and_get_response(format!("{}", command).as_slice()) } @@ -195,12 +195,12 @@ impl Client { match (&mut self.stream.clone().unwrap() as &mut Writer) .write_str(format!("{:s}{:s}", string, CRLF).as_slice()) { // TODO improve this Ok(..) => debug!("Wrote: {:s}", string), - Err(..) => fail!("Could not write to stream") + Err(..) => panic!("Could not write to stream") } match self.get_reply() { Some(response) => {debug!("Read: {}", response); response}, - None => fail!("No answer on {:s}", self.host) + None => panic!("No answer on {:s}", self.host) } } @@ -208,7 +208,7 @@ impl Client { fn get_reply(&mut self) -> Option { let response = match self.read_to_string() { Ok(string) => string, - Err(..) => fail!("No answer") + Err(..) => panic!("No answer") }; from_str::(response.as_slice()) } @@ -219,11 +219,11 @@ impl Client { if is_connected { match self.quit::() { Ok(..) => {}, - Err(response) => fail!("Failed: {}", response) + Err(response) => panic!("Failed: {}", response) } } self.close(); - fail!("Failed: {}", reason); + panic!("Failed: {}", reason); } /// Checks if the server is connected @@ -387,7 +387,7 @@ impl Reader for Client { let response = match self.read(buf) { Ok(bytes_read) => from_utf8(buf.slice_to(bytes_read - 1)).unwrap(), - Err(..) => fail!("Read error") + Err(..) => panic!("Read error") }; return Ok(response.to_string()); diff --git a/src/client/server_info.rs b/src/client/server_info.rs index 52e59fc..561de0c 100644 --- a/src/client/server_info.rs +++ b/src/client/server_info.rs @@ -47,7 +47,7 @@ impl ServerInfo { let mut esmtp_features = Vec::new(); for line in message.as_slice().split_str(CRLF) { match from_str::(line) { - Some(Response{code: 250, message: message}) => { + Some(Response{code: 250, message}) => { match from_str::(message.unwrap().as_slice()) { Some(keyword) => esmtp_features.push(keyword), None => ()