Skip to content

Commit f800835

Browse files
committed
Move error types to error module
1 parent 417fb09 commit f800835

File tree

10 files changed

+32
-27
lines changed

10 files changed

+32
-27
lines changed

src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Error types.
2+
13
use byteorder;
24
use phf;
35
use std::error;

src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ use std::vec;
7575
#[cfg(feature = "unix_socket")]
7676
use std::path::PathBuf;
7777

78-
pub use error::{Error, ConnectError, SqlState, DbError, ErrorPosition};
78+
use error::{Error, ConnectError, SqlState, DbError};
7979
#[doc(inline)]
8080
pub use types::{ToSql, FromSql};
8181
use io::{StreamWrapper, NegotiateSsl};
@@ -91,7 +91,7 @@ use url::Url;
9191
#[macro_use]
9292
mod macros;
9393

94-
mod error;
94+
pub mod error;
9595
pub mod io;
9696
mod message;
9797
mod priv_io;
@@ -964,26 +964,26 @@ impl Connection {
964964
/// ## Examples
965965
///
966966
/// ```rust,no_run
967-
/// # use postgres::{Connection, SslMode, ConnectError};
968-
/// # fn f() -> Result<(), ConnectError> {
967+
/// # use postgres::{Connection, SslMode};
968+
/// # fn f() -> Result<(), ::postgres::error::ConnectError> {
969969
/// let url = "postgresql://postgres:hunter2@localhost:2994/foodb";
970970
/// let conn = try!(Connection::connect(url, &SslMode::None));
971971
/// # Ok(()) };
972972
/// ```
973973
///
974974
/// ```rust,no_run
975-
/// # use postgres::{Connection, SslMode, ConnectError};
976-
/// # fn f() -> Result<(), ConnectError> {
975+
/// # use postgres::{Connection, SslMode};
976+
/// # fn f() -> Result<(), ::postgres::error::ConnectError> {
977977
/// let url = "postgresql://postgres@%2Frun%2Fpostgres";
978978
/// let conn = try!(Connection::connect(url, &SslMode::None));
979979
/// # Ok(()) };
980980
/// ```
981981
///
982982
/// ```rust,no_run
983983
/// # #![allow(unstable)]
984-
/// # use postgres::{Connection, UserInfo, ConnectParams, SslMode, ConnectTarget, ConnectError};
984+
/// # use postgres::{Connection, UserInfo, ConnectParams, SslMode, ConnectTarget};
985985
/// # #[cfg(feature = "unix_socket")]
986-
/// # fn f() -> Result<(), ConnectError> {
986+
/// # fn f() -> Result<(), ::postgres::error::ConnectError> {
987987
/// # let some_crazy_path = Path::new("");
988988
/// let params = ConnectParams {
989989
/// target: ConnectTarget::Unix(some_crazy_path),
@@ -1082,7 +1082,7 @@ impl Connection {
10821082
///
10831083
/// ```rust,no_run
10841084
/// # use postgres::{Connection, SslMode};
1085-
/// # fn foo() -> Result<(), postgres::Error> {
1085+
/// # fn foo() -> Result<(), postgres::error::Error> {
10861086
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
10871087
/// let trans = try!(conn.transaction());
10881088
/// try!(trans.execute("UPDATE foo SET bar = 10", &[]));

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ macro_rules! try_desync {
1313
macro_rules! check_desync {
1414
($e:expr) => ({
1515
if $e.is_desynchronized() {
16-
return Err(::Error::StreamDesynchronized);
16+
return Err(::error::Error::StreamDesynchronized);
1717
}
1818
})
1919
}
@@ -22,6 +22,6 @@ macro_rules! bad_response {
2222
($s:expr) => ({
2323
debug!("Bad response at {}:{}", file!(), line!());
2424
$s.desynchronized = true;
25-
return Err(::Error::IoError(::bad_response()));
25+
return Err(::error::Error::IoError(::bad_response()));
2626
})
2727
}

src/priv_io.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use std::os::unix::io::{AsRawFd, RawFd};
99
#[cfg(windows)]
1010
use std::os::windows::io::{AsRawSocket, RawSocket};
1111

12-
use {SslMode, ConnectError, ConnectParams, ConnectTarget};
12+
use {SslMode, ConnectParams, ConnectTarget};
13+
use error::{ConnectError};
1314
use io::{NegotiateSsl, StreamWrapper};
1415
use message::{self, WriteMessage};
1516
use message::FrontendMessage::SslRequest;

src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ macro_rules! to_sql_checked {
3535
ctx: &$crate::types::SessionInfo)
3636
-> $crate::Result<$crate::types::IsNull> {
3737
if !<Self as $crate::types::ToSql>::accepts(ty) {
38-
return Err($crate::Error::WrongType(ty.clone()));
38+
return Err($crate::error::Error::WrongType(ty.clone()));
3939
}
4040
self.to_sql(ty, out, ctx)
4141
}

src/types/rustc_serialize.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use std::error;
33
use std::io::prelude::*;
44
use byteorder::{ReadBytesExt, WriteBytesExt};
55

6-
use {Result, Error};
6+
use Result;
7+
use error::Error;
78
use types::{FromSql, ToSql, IsNull, Type, SessionInfo};
89

910
impl FromSql for json::Json {

src/types/serde.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use std::io::prelude::*;
55
use byteorder::{ReadBytesExt, WriteBytesExt};
66
use self::serde::json::{self, Value};
77

8-
use {Result, Error};
8+
use Result;
9+
use error::Error;
910
use types::{FromSql, ToSql, IsNull, Type, SessionInfo};
1011

1112
impl FromSql for Value {

src/types/slice.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::io::prelude::*;
22
use byteorder::{WriteBytesExt, BigEndian};
33

4-
use {Result, Error};
4+
use Result;
5+
use error::Error;
56
use types::{Type, ToSql, Kind, IsNull, SessionInfo};
67

78
/// An adapter type mapping slices to Postgres arrays.

tests/test.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ use postgres::{HandleNotice,
1313
Connection,
1414
GenericConnection,
1515
SslMode,
16-
Error,
17-
ConnectError,
18-
DbError,
1916
IntoConnectParams,
2017
IsolationLevel};
18+
use postgres::error::{Error, ConnectError, DbError};
2119
use postgres::types::{Type, Kind};
22-
use postgres::SqlState::{SyntaxError,
23-
QueryCanceled,
24-
UndefinedTable,
25-
InvalidCatalogName,
26-
InvalidPassword,
27-
CardinalityViolation};
28-
use postgres::ErrorPosition::Normal;
20+
use postgres::error::SqlState::{SyntaxError,
21+
QueryCanceled,
22+
UndefinedTable,
23+
InvalidCatalogName,
24+
InvalidPassword,
25+
CardinalityViolation};
26+
use postgres::error::ErrorPosition::Normal;
2927

3028
macro_rules! or_panic {
3129
($e:expr) => (

tests/types/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use std::f32;
33
use std::f64;
44
use std::fmt;
55

6-
use postgres::{Connection, SslMode, Slice, Error};
6+
use postgres::{Connection, SslMode, Slice};
7+
use postgres::error::Error;
78
use postgres::types::{ToSql, FromSql};
89

910
#[cfg(feature = "uuid")]

0 commit comments

Comments
 (0)