@@ -334,8 +334,8 @@ enum Kind {
334
334
Io ,
335
335
UnexpectedMessage ,
336
336
Tls ,
337
- ToSql ,
338
- FromSql ,
337
+ ToSql ( usize ) ,
338
+ FromSql ( usize ) ,
339
339
Column ,
340
340
CopyInStream ,
341
341
Closed ,
@@ -368,25 +368,24 @@ impl fmt::Debug for Error {
368
368
369
369
impl fmt:: Display for Error {
370
370
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
371
- let s = match self . 0 . kind {
372
- Kind :: Io => "error communicating with the server" ,
373
- Kind :: UnexpectedMessage => "unexpected message from server" ,
374
- Kind :: Tls => "error performing TLS handshake" ,
375
- Kind :: ToSql => "error serializing a value" ,
376
- Kind :: FromSql => "error deserializing a value" ,
377
- Kind :: Column => "invalid column" ,
378
- Kind :: CopyInStream => "error from a copy_in stream" ,
379
- Kind :: Closed => "connection closed" ,
380
- Kind :: Db => "db error" ,
381
- Kind :: Parse => "error parsing response from server" ,
382
- Kind :: Encode => "error encoding message to server" ,
383
- Kind :: Authentication => "authentication error" ,
384
- Kind :: ConfigParse => "invalid connection string" ,
385
- Kind :: Config => "invalid configuration" ,
371
+ match self . 0 . kind {
372
+ Kind :: Io => fmt . write_str ( "error communicating with the server" ) ? ,
373
+ Kind :: UnexpectedMessage => fmt . write_str ( "unexpected message from server" ) ? ,
374
+ Kind :: Tls => fmt . write_str ( "error performing TLS handshake" ) ? ,
375
+ Kind :: ToSql ( idx ) => write ! ( fmt , "error serializing parameter {}" , idx ) ? ,
376
+ Kind :: FromSql ( idx ) => write ! ( fmt , "error deserializing column {}" , idx ) ? ,
377
+ Kind :: Column => fmt . write_str ( "invalid column" ) ? ,
378
+ Kind :: CopyInStream => fmt . write_str ( "error from a copy_in stream" ) ? ,
379
+ Kind :: Closed => fmt . write_str ( "connection closed" ) ? ,
380
+ Kind :: Db => fmt . write_str ( "db error" ) ? ,
381
+ Kind :: Parse => fmt . write_str ( "error parsing response from server" ) ? ,
382
+ Kind :: Encode => fmt . write_str ( "error encoding message to server" ) ? ,
383
+ Kind :: Authentication => fmt . write_str ( "authentication error" ) ? ,
384
+ Kind :: ConfigParse => fmt . write_str ( "invalid connection string" ) ? ,
385
+ Kind :: Config => fmt . write_str ( "invalid configuration" ) ? ,
386
386
#[ cfg( feature = "runtime" ) ]
387
- Kind :: Connect => "error connecting to server" ,
387
+ Kind :: Connect => fmt . write_str ( "error connecting to server" ) ? ,
388
388
} ;
389
- fmt. write_str ( s) ?;
390
389
if let Some ( ref cause) = self . 0 . cause {
391
390
write ! ( fmt, ": {}" , cause) ?;
392
391
}
@@ -445,12 +444,12 @@ impl Error {
445
444
}
446
445
447
446
#[ allow( clippy:: wrong_self_convention) ]
448
- pub ( crate ) fn to_sql ( e : Box < dyn error:: Error + Sync + Send > ) -> Error {
449
- Error :: new ( Kind :: ToSql , Some ( e) )
447
+ pub ( crate ) fn to_sql ( e : Box < dyn error:: Error + Sync + Send > , idx : usize ) -> Error {
448
+ Error :: new ( Kind :: ToSql ( idx ) , Some ( e) )
450
449
}
451
450
452
- pub ( crate ) fn from_sql ( e : Box < dyn error:: Error + Sync + Send > ) -> Error {
453
- Error :: new ( Kind :: FromSql , Some ( e) )
451
+ pub ( crate ) fn from_sql ( e : Box < dyn error:: Error + Sync + Send > , idx : usize ) -> Error {
452
+ Error :: new ( Kind :: FromSql ( idx ) , Some ( e) )
454
453
}
455
454
456
455
pub ( crate ) fn column ( ) -> Error {
0 commit comments