@@ -293,7 +293,9 @@ const defaultMethods = {
293293 let lastError
294294 for ( let i = 0 ; i < arr . length ; i ++ ) {
295295 try {
296- item = executeInLoop ? engine . run ( arr [ i ] , _1 , { above : _2 } ) : arr [ i ]
296+ // Todo: make this message thing more robust.
297+ if ( lastError ) item = engine . run ( arr [ i ] , { error : lastError . message || lastError . constructor . name } , { above : [ null , _1 , _2 ] } )
298+ else item = executeInLoop ? engine . run ( arr [ i ] , _1 , { above : _2 } ) : arr [ i ]
297299 return item
298300 } catch ( e ) {
299301 // Do nothing
@@ -312,7 +314,9 @@ const defaultMethods = {
312314 let lastError
313315 for ( let i = 0 ; i < arr . length ; i ++ ) {
314316 try {
315- item = executeInLoop ? await engine . run ( arr [ i ] , _1 , { above : _2 } ) : arr [ i ]
317+ // Todo: make this message thing more robust.
318+ if ( lastError ) item = await engine . run ( arr [ i ] , { error : lastError . message || lastError . constructor . name } , { above : [ null , _1 , _2 ] } )
319+ else item = executeInLoop ? await engine . run ( arr [ i ] , _1 , { above : _2 } ) : arr [ i ]
316320 return item
317321 } catch ( e ) {
318322 // Do nothing
@@ -970,11 +974,11 @@ defaultMethods['/'].compile = function (data, buildState) {
970974 if ( Array . isArray ( data ) ) {
971975 return `(${ data . map ( ( i , x ) => {
972976 let res = numberCoercion ( i , buildState )
973- if ( x ) res = `(${ res } || (() => { throw new Error() })() )`
977+ if ( x ) res = `(${ res } || (() => { throw new Error('NaN' ) })() )`
974978 return res
975979 } ) . join ( ' / ' ) } )`
976980 }
977- return `(${ buildString ( data , buildState ) } ).reduce((a,b) => (+precoerceNumber(a))/(+precoerceNumber(b) || (() => { throw new Error() })() ))`
981+ return `(${ buildString ( data , buildState ) } ).reduce((a,b) => (+precoerceNumber(a))/(+precoerceNumber(b) || (() => { throw new Error('NaN' ) })() ))`
978982}
979983// @ts -ignore Allow custom attribute
980984defaultMethods [ '*' ] . compile = function ( data , buildState ) {
0 commit comments