File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -322,7 +322,8 @@ impl<R: BufRead> ReadMessage for R {
322
322
b't' => try!( read_parameter_description ( & mut rdr) ) ,
323
323
b'T' => try!( read_row_description ( & mut rdr) ) ,
324
324
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) ) ) ,
326
327
} ;
327
328
if rdr. limit ( ) != 0 {
328
329
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> {
377
378
6 => AuthenticationSCMCredential ,
378
379
7 => AuthenticationGSS ,
379
380
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) ) ) ,
381
383
} )
382
384
}
383
385
Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ impl FromSql for NaiveDateTime {
24
24
25
25
impl ToSql for NaiveDateTime {
26
26
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) ) ;
29
35
Ok ( IsNull :: No )
30
36
}
31
37
@@ -128,7 +134,14 @@ impl FromSql for NaiveTime {
128
134
impl ToSql for NaiveTime {
129
135
fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _: & SessionInfo ) -> Result < IsNull > {
130
136
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) ) ;
132
145
Ok ( IsNull :: No )
133
146
}
134
147
You can’t perform that action at this time.
0 commit comments