@@ -80,10 +80,8 @@ use std::fmt;
8080use error:: { InvalidUrl ,
8181 MissingPassword ,
8282 MissingUser ,
83- PgConnectDbError ,
8483 PgConnectStreamError ,
8584 PgConnectBadResponse ,
86- PgDbError ,
8785 PgInvalidColumn ,
8886 PgStreamDesynchronized ,
8987 PgStreamError ,
@@ -428,7 +426,7 @@ impl InnerPostgresConnection {
428426 }
429427 ReadyForQuery { .. } => break ,
430428 ErrorResponse { fields } =>
431- return Err ( PgConnectDbError ( PostgresDbError :: new ( fields) ) ) ,
429+ return PostgresDbError :: new_connect ( fields) ,
432430 _ => return Err ( PgConnectBadResponse ) ,
433431 }
434432 }
@@ -449,7 +447,10 @@ impl InnerPostgresConnection {
449447 loop {
450448 match try_desync ! ( self , self . stream. read_message( ) ) {
451449 NoticeResponse { fields } => {
452- self . notice_handler . handle ( PostgresDbError :: new ( fields) )
450+ match PostgresDbError :: new_raw ( fields) {
451+ Ok ( err) => self . notice_handler . handle ( err) ,
452+ Err ( ( ) ) => { }
453+ }
453454 }
454455 NotificationResponse { pid, channel, payload } => {
455456 self . notifications . push ( PostgresNotification {
@@ -500,7 +501,7 @@ impl InnerPostgresConnection {
500501 | AuthenticationSCMCredential
501502 | AuthenticationGSS
502503 | AuthenticationSSPI => return Err ( UnsupportedAuthentication ) ,
503- ErrorResponse { fields } => return Err ( PgConnectDbError ( PostgresDbError :: new ( fields) ) ) ,
504+ ErrorResponse { fields } => return PostgresDbError :: new_connect ( fields) ,
504505 _ => {
505506 self . desynchronized = true ;
506507 return Err ( PgConnectBadResponse ) ;
@@ -509,7 +510,7 @@ impl InnerPostgresConnection {
509510
510511 match try_pg_conn ! ( self . read_message_( ) ) {
511512 AuthenticationOk => Ok ( ( ) ) ,
512- ErrorResponse { fields } => Err ( PgConnectDbError ( PostgresDbError :: new ( fields) ) ) ,
513+ ErrorResponse { fields } => return PostgresDbError :: new_connect ( fields) ,
513514 _ => {
514515 self . desynchronized = true ;
515516 return Err ( PgConnectBadResponse ) ;
@@ -543,7 +544,7 @@ impl InnerPostgresConnection {
543544 ParseComplete => { }
544545 ErrorResponse { fields } => {
545546 try!( self . wait_for_ready ( ) ) ;
546- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
547+ return PostgresDbError :: new ( fields) ;
547548 }
548549 _ => bad_response ! ( self ) ,
549550 }
@@ -629,7 +630,7 @@ impl InnerPostgresConnection {
629630 ReadyForQuery { .. } => break ,
630631 ErrorResponse { fields } => {
631632 try!( self . wait_for_ready ( ) ) ;
632- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
633+ return PostgresDbError :: new ( fields) ;
633634 }
634635 _ => { }
635636 }
@@ -691,7 +692,7 @@ impl InnerPostgresConnection {
691692 }
692693 ErrorResponse { fields } => {
693694 try!( self . wait_for_ready ( ) ) ;
694- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
695+ return PostgresDbError :: new ( fields) ;
695696 }
696697 _ => { }
697698 }
@@ -1184,7 +1185,7 @@ impl<'conn> PostgresStatement<'conn> {
11841185 BindComplete => Ok ( ( ) ) ,
11851186 ErrorResponse { fields } => {
11861187 try!( conn. wait_for_ready ( ) ) ;
1187- Err ( PgDbError ( PostgresDbError :: new ( fields) ) )
1188+ PostgresDbError :: new ( fields)
11881189 }
11891190 _ => {
11901191 conn. desynchronized = true ;
@@ -1251,7 +1252,7 @@ impl<'conn> PostgresStatement<'conn> {
12511252 DataRow { .. } => { }
12521253 ErrorResponse { fields } => {
12531254 try!( conn. wait_for_ready ( ) ) ;
1254- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
1255+ return PostgresDbError :: new ( fields) ;
12551256 }
12561257 CommandComplete { tag } => {
12571258 num = util:: parse_update_count ( tag) ;
@@ -1357,7 +1358,7 @@ impl<'stmt> PostgresRows<'stmt> {
13571358 ReadyForQuery { .. } => break ,
13581359 ErrorResponse { fields } => {
13591360 try!( conn. wait_for_ready ( ) ) ;
1360- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
1361+ return PostgresDbError :: new ( fields) ;
13611362 }
13621363 _ => { }
13631364 }
@@ -1381,7 +1382,7 @@ impl<'stmt> PostgresRows<'stmt> {
13811382 DataRow { row } => self . data . push ( row) ,
13821383 ErrorResponse { fields } => {
13831384 try!( conn. wait_for_ready ( ) ) ;
1384- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
1385+ return PostgresDbError :: new ( fields) ;
13851386 }
13861387 CopyInResponse { .. } => {
13871388 try_pg ! ( conn. write_messages( [
@@ -1622,7 +1623,7 @@ impl<'a> PostgresCopyInStatement<'a> {
16221623 BindComplete => { } ,
16231624 ErrorResponse { fields } => {
16241625 try!( conn. wait_for_ready ( ) ) ;
1625- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
1626+ return PostgresDbError :: new ( fields) ;
16261627 }
16271628 _ => {
16281629 conn. desynchronized = true ;
@@ -1692,7 +1693,7 @@ impl<'a> PostgresCopyInStatement<'a> {
16921693 CommandComplete { tag } => util:: parse_update_count ( tag) ,
16931694 ErrorResponse { fields } => {
16941695 try!( conn. wait_for_ready ( ) ) ;
1695- return Err ( PgDbError ( PostgresDbError :: new ( fields) ) ) ;
1696+ return PostgresDbError :: new ( fields) ;
16961697 }
16971698 _ => {
16981699 conn. desynchronized = true ;
0 commit comments