@@ -67,14 +67,14 @@ impl DbErrorNew for DbError {
67
67
68
68
fn new_connect < T > ( fields : Vec < ( u8 , String ) > ) -> result:: Result < T , ConnectError > {
69
69
match DbError :: new_raw ( fields) {
70
- Ok ( err) => Err ( ConnectError :: DbError ( err) ) ,
70
+ Ok ( err) => Err ( ConnectError :: DbError ( Box :: new ( err) ) ) ,
71
71
Err ( ( ) ) => Err ( ConnectError :: IoError ( :: bad_response ( ) ) ) ,
72
72
}
73
73
}
74
74
75
75
fn new < T > ( fields : Vec < ( u8 , String ) > ) -> Result < T > {
76
76
match DbError :: new_raw ( fields) {
77
- Ok ( err) => Err ( Error :: DbError ( err) ) ,
77
+ Ok ( err) => Err ( Error :: DbError ( Box :: new ( err) ) ) ,
78
78
Err ( ( ) ) => Err ( Error :: IoError ( :: bad_response ( ) ) ) ,
79
79
}
80
80
}
@@ -193,30 +193,30 @@ impl error::Error for DbError {
193
193
/// Reasons a new Postgres connection could fail.
194
194
#[ derive( Debug ) ]
195
195
pub 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.
199
199
MissingUser ,
200
200
/// 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` .
203
203
MissingPassword ,
204
204
/// The Postgres server requested an authentication method not supported
205
205
/// by the driver.
206
206
UnsupportedAuthentication ,
207
207
/// The Postgres server does not support SSL encryption.
208
208
NoSslSupport ,
209
- /// There was an error initializing the SSL session.
209
+ /// An error initializing the SSL session.
210
210
SslError ( Box < error:: Error +Sync +Send > ) ,
211
- /// There was an error communicating with the server.
211
+ /// An error communicating with the server.
212
212
IoError ( io:: Error ) ,
213
213
}
214
214
215
215
impl fmt:: Display for ConnectError {
216
216
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
217
217
try!( fmt. write_str ( error:: Error :: description ( self ) ) ) ;
218
218
match * self {
219
- ConnectError :: InvalidUrl ( ref msg) => write ! ( fmt, ": {}" , msg) ,
219
+ ConnectError :: BadConnectParams ( ref msg) => write ! ( fmt, ": {}" , msg) ,
220
220
ConnectError :: DbError ( ref err) => write ! ( fmt, ": {}" , err) ,
221
221
ConnectError :: SslError ( ref err) => write ! ( fmt, ": {}" , err) ,
222
222
ConnectError :: IoError ( ref err) => write ! ( fmt, ": {}" , err) ,
@@ -228,8 +228,8 @@ impl fmt::Display for ConnectError {
228
228
impl error:: Error for ConnectError {
229
229
fn description ( & self ) -> & str {
230
230
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` " ,
233
233
ConnectError :: DbError ( _) => "Error reported by Postgres" ,
234
234
ConnectError :: MissingPassword => "The server requested a password but none was provided" ,
235
235
ConnectError :: UnsupportedAuthentication => {
@@ -243,7 +243,8 @@ impl error::Error for ConnectError {
243
243
244
244
fn cause ( & self ) -> Option < & error:: Error > {
245
245
match * self {
246
- ConnectError :: DbError ( ref err) => Some ( err) ,
246
+ ConnectError :: BadConnectParams ( ref err) => Some ( & * * err) ,
247
+ ConnectError :: DbError ( ref err) => Some ( & * * err) ,
247
248
ConnectError :: SslError ( ref err) => Some ( & * * err) ,
248
249
ConnectError :: IoError ( ref err) => Some ( err) ,
249
250
_ => None
@@ -259,7 +260,7 @@ impl From<io::Error> for ConnectError {
259
260
260
261
impl From < DbError > for ConnectError {
261
262
fn from ( err : DbError ) -> ConnectError {
262
- ConnectError :: DbError ( err)
263
+ ConnectError :: DbError ( Box :: new ( err) )
263
264
}
264
265
}
265
266
@@ -287,7 +288,7 @@ pub enum ErrorPosition {
287
288
#[ derive( Debug ) ]
288
289
pub enum Error {
289
290
/// An error reported by the Postgres server.
290
- DbError ( DbError ) ,
291
+ DbError ( Box < DbError > ) ,
291
292
/// An error communicating with the Postgres server.
292
293
IoError ( io:: Error ) ,
293
294
/// An attempt was made to convert between incompatible Rust and Postgres
@@ -325,7 +326,7 @@ impl error::Error for Error {
325
326
326
327
fn cause ( & self ) -> Option < & error:: Error > {
327
328
match * self {
328
- Error :: DbError ( ref err) => Some ( err) ,
329
+ Error :: DbError ( ref err) => Some ( & * * err) ,
329
330
Error :: IoError ( ref err) => Some ( err) ,
330
331
Error :: Conversion ( ref err) => Some ( & * * err) ,
331
332
_ => None
@@ -335,7 +336,7 @@ impl error::Error for Error {
335
336
336
337
impl From < DbError > for Error {
337
338
fn from ( err : DbError ) -> Error {
338
- Error :: DbError ( err)
339
+ Error :: DbError ( Box :: new ( err) )
339
340
}
340
341
}
341
342
0 commit comments