Skip to content

Commit 5d5caac

Browse files
committed
Use shared error type
1 parent 3b8fc56 commit 5d5caac

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

postgres-tokio/src/lib.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,32 @@ extern crate futures;
99

1010
use futures::{Future, IntoFuture, BoxFuture, Stream, Sink, Poll, StartSend};
1111
use futures::future::Either;
12-
use postgres_shared::params::{ConnectParams, IntoConnectParams};
1312
use postgres_protocol::authentication;
1413
use postgres_protocol::message::{backend, frontend};
1514
use std::collections::HashMap;
16-
use std::error::Error;
1715
use std::io;
1816
use tokio_core::reactor::Handle;
1917

18+
#[doc(inline)]
19+
pub use postgres_shared::error;
20+
#[doc(inline)]
21+
pub use postgres_shared::params;
22+
23+
use error::ConnectError;
24+
use params::{ConnectParams, IntoConnectParams};
2025
use stream::PostgresStream;
2126

2227
mod stream;
2328

2429
#[cfg(test)]
2530
mod test;
2631

27-
#[derive(Debug)]
28-
pub enum ConnectError {
29-
Params(Box<Error + Sync + Send>),
30-
Io(io::Error),
31-
}
32-
3332
#[derive(Debug, Copy, Clone)]
3433
pub struct CancelData {
3534
pub process_id: i32,
3635
pub secret_key: i32,
3736
}
3837

39-
impl From<io::Error> for ConnectError {
40-
fn from(e: io::Error) -> ConnectError {
41-
ConnectError::Io(e)
42-
}
43-
}
44-
4538
struct InnerConnectionState {
4639
parameters: HashMap<String, String>,
4740
cancel_data: CancelData,
@@ -116,7 +109,7 @@ impl Connection {
116109
{
117110
let params = match params.into_connect_params() {
118111
Ok(params) => params,
119-
Err(e) => return futures::failed(ConnectError::Params(e)).boxed(),
112+
Err(e) => return futures::failed(ConnectError::ConnectParams(e)).boxed(),
120113
};
121114

122115
stream::connect(params.host(), params.port(), handle)
@@ -175,7 +168,7 @@ impl Connection {
175168
.map_err(Into::into)
176169
}
177170
None => {
178-
Err(ConnectError::Params(
171+
Err(ConnectError::ConnectParams(
179172
"password was required but not provided".into()))
180173
}
181174
}
@@ -192,7 +185,7 @@ impl Connection {
192185
.map_err(Into::into)
193186
}
194187
None => {
195-
Err(ConnectError::Params(
188+
Err(ConnectError::ConnectParams(
196189
"password was required but not provided".into()))
197190
}
198191
}

0 commit comments

Comments
 (0)