@@ -67,14 +67,14 @@ impl DbErrorNew for DbError {
6767
6868 fn new_connect < T > ( fields : Vec < ( u8 , String ) > ) -> result:: Result < T , ConnectError > {
6969 match DbError :: new_raw ( fields) {
70- Ok ( err) => Err ( ConnectError :: DbError ( err) ) ,
70+ Ok ( err) => Err ( ConnectError :: DbError ( Box :: new ( err) ) ) ,
7171 Err ( ( ) ) => Err ( ConnectError :: IoError ( :: bad_response ( ) ) ) ,
7272 }
7373 }
7474
7575 fn new < T > ( fields : Vec < ( u8 , String ) > ) -> Result < T > {
7676 match DbError :: new_raw ( fields) {
77- Ok ( err) => Err ( Error :: DbError ( err) ) ,
77+ Ok ( err) => Err ( Error :: DbError ( Box :: new ( err) ) ) ,
7878 Err ( ( ) ) => Err ( Error :: IoError ( :: bad_response ( ) ) ) ,
7979 }
8080 }
@@ -193,30 +193,30 @@ impl error::Error for DbError {
193193/// Reasons a new Postgres connection could fail.
194194#[ derive( Debug ) ]
195195pub enum ConnectError {
196- /// The provided URL could not be parsed .
197- InvalidUrl ( String ) ,
198- /// The URL was missing a user.
196+ /// An error creating `ConnectParams` .
197+ BadConnectParams ( Box < error :: Error + Sync + Send > ) ,
198+ /// The `ConnectParams` was missing a user.
199199 MissingUser ,
200200 /// An error from the Postgres server itself.
201- DbError ( DbError ) ,
202- /// A password was required but not provided in the URL .
201+ DbError ( Box < DbError > ) ,
202+ /// A password was required but not provided in the `ConnectParams` .
203203 MissingPassword ,
204204 /// The Postgres server requested an authentication method not supported
205205 /// by the driver.
206206 UnsupportedAuthentication ,
207207 /// The Postgres server does not support SSL encryption.
208208 NoSslSupport ,
209- /// There was an error initializing the SSL session.
209+ /// An error initializing the SSL session.
210210 SslError ( Box < error:: Error +Sync +Send > ) ,
211- /// There was an error communicating with the server.
211+ /// An error communicating with the server.
212212 IoError ( io:: Error ) ,
213213}
214214
215215impl fmt:: Display for ConnectError {
216216 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
217217 try!( fmt. write_str ( error:: Error :: description ( self ) ) ) ;
218218 match * self {
219- ConnectError :: InvalidUrl ( ref msg) => write ! ( fmt, ": {}" , msg) ,
219+ ConnectError :: BadConnectParams ( ref msg) => write ! ( fmt, ": {}" , msg) ,
220220 ConnectError :: DbError ( ref err) => write ! ( fmt, ": {}" , err) ,
221221 ConnectError :: SslError ( ref err) => write ! ( fmt, ": {}" , err) ,
222222 ConnectError :: IoError ( ref err) => write ! ( fmt, ": {}" , err) ,
@@ -228,8 +228,8 @@ impl fmt::Display for ConnectError {
228228impl error:: Error for ConnectError {
229229 fn description ( & self ) -> & str {
230230 match * self {
231- ConnectError :: InvalidUrl ( _) => "Invalid URL " ,
232- ConnectError :: MissingUser => "User missing in URL " ,
231+ ConnectError :: BadConnectParams ( _) => "Error creating `ConnectParams` " ,
232+ ConnectError :: MissingUser => "User missing in `ConnectParams` " ,
233233 ConnectError :: DbError ( _) => "Error reported by Postgres" ,
234234 ConnectError :: MissingPassword => "The server requested a password but none was provided" ,
235235 ConnectError :: UnsupportedAuthentication => {
@@ -243,7 +243,8 @@ impl error::Error for ConnectError {
243243
244244 fn cause ( & self ) -> Option < & error:: Error > {
245245 match * self {
246- ConnectError :: DbError ( ref err) => Some ( err) ,
246+ ConnectError :: BadConnectParams ( ref err) => Some ( & * * err) ,
247+ ConnectError :: DbError ( ref err) => Some ( & * * err) ,
247248 ConnectError :: SslError ( ref err) => Some ( & * * err) ,
248249 ConnectError :: IoError ( ref err) => Some ( err) ,
249250 _ => None
@@ -259,7 +260,7 @@ impl From<io::Error> for ConnectError {
259260
260261impl From < DbError > for ConnectError {
261262 fn from ( err : DbError ) -> ConnectError {
262- ConnectError :: DbError ( err)
263+ ConnectError :: DbError ( Box :: new ( err) )
263264 }
264265}
265266
@@ -287,7 +288,7 @@ pub enum ErrorPosition {
287288#[ derive( Debug ) ]
288289pub enum Error {
289290 /// An error reported by the Postgres server.
290- DbError ( DbError ) ,
291+ DbError ( Box < DbError > ) ,
291292 /// An error communicating with the Postgres server.
292293 IoError ( io:: Error ) ,
293294 /// An attempt was made to convert between incompatible Rust and Postgres
@@ -325,7 +326,7 @@ impl error::Error for Error {
325326
326327 fn cause ( & self ) -> Option < & error:: Error > {
327328 match * self {
328- Error :: DbError ( ref err) => Some ( err) ,
329+ Error :: DbError ( ref err) => Some ( & * * err) ,
329330 Error :: IoError ( ref err) => Some ( err) ,
330331 Error :: Conversion ( ref err) => Some ( & * * err) ,
331332 _ => None
@@ -335,7 +336,7 @@ impl error::Error for Error {
335336
336337impl From < DbError > for Error {
337338 fn from ( err : DbError ) -> Error {
338- Error :: DbError ( err)
339+ Error :: DbError ( Box :: new ( err) )
339340 }
340341}
341342
0 commit comments