File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -322,7 +322,8 @@ impl<R: BufRead> ReadMessage for R {
322322 b't' => try!( read_parameter_description ( & mut rdr) ) ,
323323 b'T' => try!( read_row_description ( & mut rdr) ) ,
324324 b'Z' => ReadyForQuery { _state : try!( rdr. read_u8 ( ) ) } ,
325- _ => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "unexpected message tag" ) ) ,
325+ t => return Err ( io:: Error :: new ( io:: ErrorKind :: Other ,
326+ format ! ( "unexpected message tag `{}`" , t) ) ) ,
326327 } ;
327328 if rdr. limit ( ) != 0 {
328329 return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "didn't read entire message" ) ) ;
@@ -377,7 +378,8 @@ fn read_auth_message<R: Read>(buf: &mut R) -> io::Result<BackendMessage> {
377378 6 => AuthenticationSCMCredential ,
378379 7 => AuthenticationGSS ,
379380 9 => AuthenticationSSPI ,
380- _ => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "unexpected authentication tag" ) ) ,
381+ t => return Err ( io:: Error :: new ( io:: ErrorKind :: Other ,
382+ format ! ( "unexpected authentication tag `{}`" , t) ) ) ,
381383 } )
382384}
383385
Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ impl FromSql for NaiveDateTime {
2424
2525impl ToSql for NaiveDateTime {
2626 fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _: & SessionInfo ) -> Result < IsNull > {
27- let t = ( * self - base ( ) ) . num_microseconds ( ) . unwrap ( ) ;
28- try!( w. write_i64 :: < BigEndian > ( t) ) ;
27+ let time = match ( * self - base ( ) ) . num_microseconds ( ) {
28+ Some ( time) => time,
29+ None => {
30+ let err: Box < error:: Error +Sync +Send > = "value too large to transmit" . into ( ) ;
31+ return Err ( Error :: Conversion ( err) ) ;
32+ }
33+ } ;
34+ try!( w. write_i64 :: < BigEndian > ( time) ) ;
2935 Ok ( IsNull :: No )
3036 }
3137
@@ -128,7 +134,14 @@ impl FromSql for NaiveTime {
128134impl ToSql for NaiveTime {
129135 fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _: & SessionInfo ) -> Result < IsNull > {
130136 let delta = * self - NaiveTime :: from_hms ( 0 , 0 , 0 ) ;
131- try!( w. write_i64 :: < BigEndian > ( delta. num_microseconds ( ) . unwrap ( ) ) ) ;
137+ let time = match delta. num_microseconds ( ) {
138+ Some ( time) => time,
139+ None => {
140+ let err: Box < error:: Error +Sync +Send > = "value too large to transmit" . into ( ) ;
141+ return Err ( Error :: Conversion ( err) ) ;
142+ }
143+ } ;
144+ try!( w. write_i64 :: < BigEndian > ( time) ) ;
132145 Ok ( IsNull :: No )
133146 }
134147
You can’t perform that action at this time.
0 commit comments