File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 20
20
import StreamObserver from './internal/stream-observer' ;
21
21
import Result from './result' ;
22
22
import Transaction from './transaction' ;
23
+ import { newError } from "./error" ;
23
24
24
25
/**
25
26
* A Session instance is used for handling the connection and
@@ -58,8 +59,9 @@ class Session {
58
59
this . _conn . pullAll ( streamObserver ) ;
59
60
this . _conn . sync ( ) ;
60
61
} else {
61
- streamObserver . onError ( { error : "Please close the currently open transaction object before running " +
62
- "more statements/transactions in the current session." } ) ;
62
+ streamObserver . onError ( newError ( "Statements cannot be run directly on a "
63
+ + "session with an open transaction; either run from within the "
64
+ + "transaction or use a different session." ) ) ;
63
65
}
64
66
return new Result ( streamObserver , statement , parameters ) ;
65
67
}
@@ -74,7 +76,9 @@ class Session {
74
76
*/
75
77
beginTransaction ( ) {
76
78
if ( this . _hasTx ) {
77
- throw new newError ( "Cannot have multiple transactions open for the session. Use multiple sessions or close the transaction before opening a new one." )
79
+ throw new newError ( "You cannot begin a transaction on a session with an "
80
+ + "open transaction; either run from within the transaction or use a "
81
+ + "different session." )
78
82
}
79
83
80
84
this . _hasTx = true ;
Original file line number Diff line number Diff line change @@ -234,8 +234,9 @@ describe('session', function() {
234
234
//Then
235
235
session . run ( "RETURN 42" )
236
236
. catch ( function ( error ) {
237
- expect ( error . error ) . toBe ( "Please close the currently open transaction object before running " +
238
- "more statements/transactions in the current session." ) ;
237
+ expect ( error . message ) . toBe ( "Statements cannot be run directly on a "
238
+ + "session with an open transaction; either run from within the "
239
+ + "transaction or use a different session." ) ;
239
240
done ( ) ;
240
241
} )
241
242
} ) ;
You can’t perform that action at this time.
0 commit comments