Clean up bad response logic a bit
This commit is contained in:
parent
e7f66f89ac
commit
1908821e57
16
src/lib.rs
16
src/lib.rs
@ -417,7 +417,6 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_message(&mut self) -> IoResult<BackendMessage> {
|
fn read_message(&mut self) -> IoResult<BackendMessage> {
|
||||||
debug_assert!(!self.desynchronized);
|
|
||||||
loop {
|
loop {
|
||||||
match try!(self.read_message_with_notification()) {
|
match try!(self.read_message_with_notification()) {
|
||||||
NotificationResponse { pid, channel, payload } => {
|
NotificationResponse { pid, channel, payload } => {
|
||||||
@ -460,19 +459,13 @@ impl InnerConnection {
|
|||||||
| AuthenticationGSS
|
| AuthenticationGSS
|
||||||
| AuthenticationSSPI => return Err(ConnectError::UnsupportedAuthentication),
|
| AuthenticationSSPI => return Err(ConnectError::UnsupportedAuthentication),
|
||||||
ErrorResponse { fields } => return DbError::new_connect(fields),
|
ErrorResponse { fields } => return DbError::new_connect(fields),
|
||||||
_ => {
|
_ => return Err(ConnectError::BadResponse)
|
||||||
self.desynchronized = true;
|
|
||||||
return Err(ConnectError::BadResponse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match try!(self.read_message()) {
|
match try!(self.read_message()) {
|
||||||
AuthenticationOk => Ok(()),
|
AuthenticationOk => Ok(()),
|
||||||
ErrorResponse { fields } => return DbError::new_connect(fields),
|
ErrorResponse { fields } => return DbError::new_connect(fields),
|
||||||
_ => {
|
_ => return Err(ConnectError::BadResponse)
|
||||||
self.desynchronized = true;
|
|
||||||
return Err(ConnectError::BadResponse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,10 +577,7 @@ impl InnerConnection {
|
|||||||
let resp = match try!(self.read_message()) {
|
let resp = match try!(self.read_message()) {
|
||||||
CloseComplete => Ok(()),
|
CloseComplete => Ok(()),
|
||||||
ErrorResponse { fields } => DbError::new(fields),
|
ErrorResponse { fields } => DbError::new(fields),
|
||||||
_ => {
|
_ => bad_response!(self)
|
||||||
self.desynchronized = true;
|
|
||||||
return Err(Error::BadResponse);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
try!(self.wait_for_ready());
|
try!(self.wait_for_ready());
|
||||||
resp
|
resp
|
||||||
|
Loading…
Reference in New Issue
Block a user