Error message - which line?JMP helps the user to find errors in the code. If an unresolved name is used in the code, JMP stops the evaluation and shows an error message - pointing to the erronous line of code
print(1);
result = x + zzz_missing;

Let's make a slight change to the code. When JMP runs this code
myFunc = Function( {x},
{},
result = x + zzz_missing;
Return( result );
);
myFunc( 3 );
it returns again an error message:

But it points to line 3 of the code where x is defined. This is very surprising: the error "happens" in line 4 : the user missed a Name expr() to protect result - and JMP accidentally evaluates the expression!
As we have already discussed this behavior in another post ( Error tracing: JMP tries to "help" ), we will directly move on to the next surprise.
Indeed, even more surprising is the error message for this code:
myFunc = Function( {x},
{Default Local},
result = x + zzz_missing;
Return( result );
);
myFunc( 3 );

-> no info about the line !?! - not even a wrong one.
why?
Automation and ScriptingRe: Error message - which line?Same restriction with Try(): no info about the line of code
Try(
result = zzz_missing;
Print( 1 );
,
Print( exception_msg )
);

Re: Error message - which line?Is there a command
- like log Capture() or Try() - which doesn't stop when there is an error in the enclosed expression
- which returns the line of code that produces the error?
Re: Error message - which line? Log Capture
according to scripting index, it captures the output to the log and returns it as a string.

but it does more than this!
It acts like try() - and allows the execution of the code to continue after a fatal error inside the evaluated expression.
log=Log capture(
result = zzz_missing;
print(1)
);
Print(2);
Show(log)
print(1) is skipped - print(2) is executed.

almost perfect. Unfortunately (!) it forgets to write the line of code where the error occurs!
Re: Error message - which line?Ah: Error Types by Vince Faller

@Ryan_Gilmore , could you please re-activate the wish for voting.
@Ben_BarrIngh , @russ_wolfinger , fyi.
Re: Error message - which line?maybe combine the request with this one:
Improved JSL Stack Trace in Log on Error
Re: Error message - which line?By the way - does anybody know what is returned in the exception message ?

1?
2?
Re: Error message - which line?Can a JSL code trigger a "child" execution - which might die with an error message about the line of error?
And the main code still survives and is executed further, either when the child execution is finished - or when the child execution is terminated?
Re: Error message - which line?// demo command
MyExpr = Expr(
Print( 1 );
z = 5;
x = xyz;
Print( 2 );
);
stopnow = 0; // if there is an error, don't execute subsequent blocks of code
summary = "";
// execute blocks of code and collect replies and error messages
For Each( {part, line}, Name Expr( myExpr ),
Try(
Eval( Name Expr( part ) );
new = "";
,
new = "part " || Char( line ) || ": " || Char( Name Expr( part ) ) || "\!n" || Char( exception_msg );
stopNow = 1;
);
Wait( 0 );
summary = summary || new || (tmp = Char( Get Log( -1 )[1] ) ; If( tmp == "/*:", "", "\!N" || tmp || "\!N" ));
Clear Log();
If( stopnow, break() );
);
Show(summary);

Assumes trivial code with <=1 reply per code block.
Can be easily extended to work with more complicated code.