@@ -1082,9 +1082,9 @@ class TcpConnection extends Connection
1082
1082
1083
1083
handshake_error = (code , message ) =>
1084
1084
if 10 <= code <= 20
1085
- throw new err.ReqlAuthError (message)
1085
+ @ emit ' error ' , new err.ReqlAuthError (message)
1086
1086
else
1087
- throw new err.ReqlDriverError (message)
1087
+ @ emit ' error ' , new err.ReqlDriverError (message)
1088
1088
1089
1089
handshake_callback = (buf ) =>
1090
1090
# Once we receive a response, extend the current
@@ -1114,6 +1114,7 @@ class TcpConnection extends Connection
1114
1114
if state is 1
1115
1115
if not server_reply .success
1116
1116
handshake_error (server_reply .error_code , server_reply .error )
1117
+ return
1117
1118
min = server_reply .min_protocol_version
1118
1119
max = server_reply .max_protocol_version
1119
1120
@@ -1126,6 +1127,7 @@ class TcpConnection extends Connection
1126
1127
else if state is 2
1127
1128
if not server_reply .success
1128
1129
handshake_error (server_reply .error_code , server_reply .error )
1130
+ return
1129
1131
1130
1132
authentication = {}
1131
1133
server_first_message = server_reply .authentication
@@ -1167,6 +1169,7 @@ class TcpConnection extends Connection
1167
1169
else if state is 3
1168
1170
if not server_reply .success
1169
1171
handshake_error (server_reply .error_code , server_reply .error )
1172
+ return
1170
1173
1171
1174
first_equals = server_reply .authentication .indexOf (' =' )
1172
1175
v = server_reply .authentication .slice (first_equals+ 1 )
@@ -1632,13 +1635,12 @@ module.exports.connect = varar 0, 2, (hostOrCallback, callback) ->
1632
1635
# or in the browser.
1633
1636
# 2. Initializes the connection, and when it's complete invokes
1634
1637
# the user's callback
1635
- if host .authKey ? && (host .password ? || host .user ? )
1636
- throw new err.ReqlDriverError " Cannot use both authKey and password"
1637
- else if host .authKey
1638
- host .user = " admin"
1639
- host .password = host .authKey
1640
-
1641
1638
new Promise ( (resolve , reject ) ->
1639
+ if host .authKey ? && (host .password ? || host .user ? )
1640
+ throw new err.ReqlDriverError " Cannot use both authKey and password"
1641
+ else if host .authKey
1642
+ host .user = " admin"
1643
+ host .password = host .authKey
1642
1644
create_connection = (host , callback ) =>
1643
1645
if TcpConnection .isAvailable ()
1644
1646
new TcpConnection host, callback
0 commit comments