Skip to content

Commit 7938377

Browse files
committed
In the Ruby driver, there is a case where InvalidSession is raised instead of SessionEnded. In addition, SessionEnded should inherit from InvalidSession, not from just Error.
1 parent 5960f5f commit 7938377

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

lib/mongo/error/session_ended.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class Error
2121
# Session was previously ended.
2222
#
2323
# @since 2.7.0
24-
class SessionEnded < Error
24+
class SessionEnded < InvalidSession
2525
def initialize
26-
super("The session was ended and cannot be used")
26+
super('The session was ended and cannot be used. Please create a new session.')
2727
end
2828
end
2929
end

lib/mongo/session.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,6 @@ def session_id
297297
'of the client owning this operation. Please only use this session for operations through its parent ' +
298298
'client.'.freeze
299299

300-
# Error message describing that the session cannot be used because it has already been ended.
301-
#
302-
# @since 2.5.0
303-
SESSION_ENDED_ERROR_MSG = 'This session has ended and cannot be used. Please create a new one.'.freeze
304-
305300
# Error message describing that sessions are not supported by the server version.
306301
#
307302
# @since 2.5.0
@@ -1251,7 +1246,7 @@ def set_operation_time(result)
12511246
end
12521247

12531248
def check_if_ended!
1254-
raise Mongo::Error::InvalidSession.new(SESSION_ENDED_ERROR_MSG) if ended?
1249+
raise Mongo::Error::SessionEnded if ended?
12551250
end
12561251

12571252
def check_matching_cluster!(client)

0 commit comments

Comments
 (0)