@@ -40,6 +40,10 @@ pub enum QueryError {
4040
4141 #[ error( "Unable to allocate stream id" ) ]
4242 UnableToAllocStreamId ,
43+
44+ /// Client timeout occurred before any response arrived
45+ #[ error( "Request timeout: {0}" ) ]
46+ RequestTimeout ( String ) ,
4347}
4448
4549/// An error sent from the database in response to a query
@@ -292,6 +296,11 @@ pub enum NewSessionError {
292296
293297 #[ error( "Unable to allocate stream id" ) ]
294298 UnableToAllocStreamId ,
299+
300+ /// Client timeout occurred before a response arrived for some query
301+ /// during `Session` creation.
302+ #[ error( "Client timeout: {0}" ) ]
303+ RequestTimeout ( String ) ,
295304}
296305
297306/// Invalid keyspace name given to `Session::use_keyspace()`
@@ -340,6 +349,12 @@ impl From<FrameError> for QueryError {
340349 }
341350}
342351
352+ impl From < tokio:: time:: error:: Elapsed > for QueryError {
353+ fn from ( timer_error : tokio:: time:: error:: Elapsed ) -> QueryError {
354+ QueryError :: RequestTimeout ( format ! ( "{}" , timer_error) )
355+ }
356+ }
357+
343358impl From < std:: io:: Error > for NewSessionError {
344359 fn from ( io_error : std:: io:: Error ) -> NewSessionError {
345360 NewSessionError :: IoError ( Arc :: new ( io_error) )
@@ -359,6 +374,7 @@ impl From<QueryError> for NewSessionError {
359374 NewSessionError :: TooManyOrphanedStreamIds ( ids)
360375 }
361376 QueryError :: UnableToAllocStreamId => NewSessionError :: UnableToAllocStreamId ,
377+ QueryError :: RequestTimeout ( msg) => NewSessionError :: RequestTimeout ( msg) ,
362378 }
363379 }
364380}
0 commit comments