File tree Expand file tree Collapse file tree 2 files changed +33
-5
lines changed
Expand file tree Collapse file tree 2 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 11const Statistics = require ( "./statistics" ) ,
22 Record = require ( "./record" ) ;
3- Node = require ( "./node" ) ;
4- Edge = require ( "./edge" ) ;
3+ Node = require ( "./node" ) ;
4+ Edge = require ( "./edge" ) ;
5+ ReplyError = require ( "redis" ) . ReplyError
56
67const ResultSetColumnTypes = {
78 COLUMN_UNKNOWN : 0 ,
@@ -40,9 +41,11 @@ class ResultSet {
4041 * The last list is the statistics list.
4142 */
4243 async parseResponse ( resp ) {
43- if ( Array . isArray ( resp ) ) {
44- if ( resp . length < 3 ) {
45- this . _statistics = new Statistics ( resp [ resp . length - 1 ] ) ;
44+ if ( Array . isArray ( resp ) ) {
45+ let statistics = resp [ resp . length - 1 ] ;
46+ if ( statistics instanceof ReplyError ) throw statistics ;
47+ if ( resp . length < 3 ) {
48+ this . _statistics = new Statistics ( statistics ) ;
4649 } else {
4750 await this . parseResults ( resp ) ;
4851 this . _resultsCount = this . _results . length ;
Original file line number Diff line number Diff line change @@ -263,4 +263,29 @@ describe('RedisGraphAPI Test', function () {
263263 console . log ( error ) ;
264264 } )
265265 } )
266+
267+ it ( 'testCompileTimeException' , ( done ) => {
268+ api . query ( "CREATE ()" ) . then ( response => {
269+ api . query ( "RETURN toUpper(5)" ) . then ( response => assert ( false ) ) . catch ( err => {
270+ assert ( err instanceof redis . ReplyError ) ;
271+ assert . equal ( err . message , "Type mismatch: expected String but was Integer" ) ;
272+ done ( ) ;
273+ } )
274+ } ) . catch ( error => {
275+ console . log ( error ) ;
276+ } )
277+ } )
278+
279+ it ( 'testRuntimeException' , ( done ) => {
280+ api . query ( "CREATE ({val:5})" ) . then ( response => {
281+ api . query ( "MATCH (n) RETURN toUpper(n.val)" ) . then ( response => assert ( false ) ) . catch ( err => {
282+ assert ( err instanceof redis . ReplyError ) ;
283+ assert . equal ( err . message , "Type mismatch: expected String but was Integer" ) ;
284+ done ( ) ;
285+ } )
286+ } ) . catch ( error => {
287+ console . log ( error ) ;
288+ } )
289+ } )
290+
266291} ) ;
You can’t perform that action at this time.
0 commit comments