File tree Expand file tree Collapse file tree 7 files changed +67
-7
lines changed
Expand file tree Collapse file tree 7 files changed +67
-7
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,21 @@ module.exports = ({
7171 } ) ;
7272 await utils . sleep ( ) ;
7373 let res = await conns . web . app . service ( servicePath ) . get ( id ) ;
74- const data = expr . evaluate ( res ) || { } ;
74+ let data = { } ;
75+ if ( expr ) try {
76+ data = expr . evaluate ( res ) ;
77+ } catch ( err ) {
78+ if ( err . message ) {
79+ output . push ( [ {
80+ text : 'Eval error' ,
81+ tail : ':'
82+ } , id ] ) ;
83+ output . push ( err . message ) ;
84+ break ;
85+ } else {
86+ throw err ;
87+ }
88+ }
7589
7690 if ( p . dry_run ) {
7791 output . push ( [ {
Original file line number Diff line number Diff line change @@ -74,7 +74,21 @@ module.exports = ({
7474 } ) ;
7575 await utils . sleep ( ) ;
7676 const res = await conns . web . app . service ( servicePath ) . get ( item . _id ) ;
77- const data = expr ? expr . evaluate ( res ) : res ;
77+ let data = res ;
78+ if ( expr ) try {
79+ data = expr . evaluate ( res ) ;
80+ } catch ( err ) {
81+ if ( err . message ) {
82+ output . push ( [ {
83+ text : 'Eval error' ,
84+ tail : ':'
85+ } , fn ] ) ;
86+ output . push ( err . message ) ;
87+ break ;
88+ } else {
89+ throw err ;
90+ }
91+ }
7892
7993 if ( p . dry_run ) {
8094 output . push ( [ {
Original file line number Diff line number Diff line change @@ -15,12 +15,15 @@ const {
1515 FeathersError
1616} = require ( '@feathersjs/errors' ) ;
1717
18- function print ( obj , p ) {
18+ function print ( obj , p = { } ) {
1919 if ( obj instanceof FeathersError ) {
2020 console . log ( chalk `{inverse ERR! } ${ obj . message } ` ) ;
2121 console . log ( jsome . getColoredString ( obj . toJSON ( ) ) ) ;
2222 } else if ( obj instanceof Error ) {
2323 console . log ( chalk `{inverse ERR! } ${ obj . message } ` ) ;
24+ } else if ( typeof obj === 'object' && obj . stack && obj . code && obj . message ) {
25+ // JSONata evaluate errors
26+ console . log ( chalk `{inverse ERR! } ${ obj . message } ` ) ;
2427 } else if ( Array . isArray ( obj ) ) {
2528 obj . forEach ( el => {
2629 if ( Array . isArray ( el ) ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " @dendra-science/dendra-cli" ,
3- "version" : " 1.2.5 " ,
3+ "version" : " 1.2.6 " ,
44 "description" : " Dendra command line interface tool." ,
55 "license" : " BSD-2-Clause-FreeBSD" ,
66 "author" : " J. Scott Smith <scott@newleafsolutionsinc.com>" ,
Original file line number Diff line number Diff line change @@ -67,7 +67,20 @@ module.exports = (
6767 await utils . sleep ( )
6868
6969 let res = await conns . web . app . service ( servicePath ) . get ( id )
70- const data = expr . evaluate ( res ) || { }
70+ let data = { }
71+
72+ if ( expr )
73+ try {
74+ data = expr . evaluate ( res )
75+ } catch ( err ) {
76+ if ( err . message ) {
77+ output . push ( [ { text : 'Eval error' , tail : ':' } , id ] )
78+ output . push ( err . message )
79+ break
80+ } else {
81+ throw err
82+ }
83+ }
7184
7285 if ( p . dry_run ) {
7386 output . push ( [ { text : 'Will patch' , tail : ':' } , id ] )
Original file line number Diff line number Diff line change @@ -68,7 +68,20 @@ module.exports = (
6868 await utils . sleep ( )
6969
7070 const res = await conns . web . app . service ( servicePath ) . get ( item . _id )
71- const data = expr ? expr . evaluate ( res ) : res
71+ let data = res
72+
73+ if ( expr )
74+ try {
75+ data = expr . evaluate ( res )
76+ } catch ( err ) {
77+ if ( err . message ) {
78+ output . push ( [ { text : 'Eval error' , tail : ':' } , fn ] )
79+ output . push ( err . message )
80+ break
81+ } else {
82+ throw err
83+ }
84+ }
7285
7386 if ( p . dry_run ) {
7487 output . push ( [ { text : 'Will save' , tail : ':' } , fn ] )
Original file line number Diff line number Diff line change @@ -10,12 +10,15 @@ const chalk = require('chalk')
1010const jsome = require ( 'jsome' )
1111const { FeathersError } = require ( '@feathersjs/errors' )
1212
13- function print ( obj , p ) {
13+ function print ( obj , p = { } ) {
1414 if ( obj instanceof FeathersError ) {
1515 console . log ( chalk `{inverse ERR! } ${ obj . message } ` )
1616 console . log ( jsome . getColoredString ( obj . toJSON ( ) ) )
1717 } else if ( obj instanceof Error ) {
1818 console . log ( chalk `{inverse ERR! } ${ obj . message } ` )
19+ } else if ( typeof obj === 'object' && obj . stack && obj . code && obj . message ) {
20+ // JSONata evaluate errors
21+ console . log ( chalk `{inverse ERR! } ${ obj . message } ` )
1922 } else if ( Array . isArray ( obj ) ) {
2023 obj . forEach ( el => {
2124 if ( Array . isArray ( el ) ) {
You can’t perform that action at this time.
0 commit comments