[Thread Prev][Thread Next][Index]

Re: [ferret_users] printing filename and line number at error



Hi Andrew,

In general the text of the line is already reported, as executed, that is after parsing for symbol and grave-accent evaluations.  So, for instance if I have a script

! define_variable.jnl
cancel mode verify

let ($varname) = 12

and I call it with a symbol value that will cause an error

yes? set redirect/tee/clobber/file=run_script.log

yes? define symbol varname = 400
yes? go define_variable
! Enter_GO define_variable
cancel mode verify
 **ERROR: command syntax: illegal name: 400
DEFINE VARIABLE 400 = 12
! Exit_GO

The result of the error-handling is the lines:

 **ERROR: command syntax: illegal name: 400
DEFINE VARIABLE 400 = 12

And the "SET REDIRECT" at the start of the session has added the lines starting with ! Enter_GO and   ! Exit_GO.

so we're proposing here, to amend this to something like

 **ERROR: command syntax: illegal name: 400
DEFINE VARIABLE 400 = 12
Running script define_variable.jnl

Or maybe that could coach us to go back and make use of SET REDIRECT.


 
**ERROR: ...
Running script define_variable.jnl.  Start session with SET REDIRECT for a complete log

I'm not sure that any of this adds much more than the output of the SET REDIRECT log.  Some ideas:

-- Maybe some options on FshowGO to list some more context on the GO commands?

-- The error listing shows the parsed command; also include the un-parsed command?

-- A separate idea which is that when running interactively it'd be nice to be able to get at the name of the current script being run, for purposes of debugging a big tree of scripts.

-Ansley

On 1/28/2020 9:52 AM, Andrew Wittenberg - NOAA Federal wrote:
Thanks Ansley!

I agree that (optionally) providing some context for error messages would be very helpful.  Perhaps could be implemented as a MODE TRACEBACK.  It could start with the name of the script, but could also be extended into a full hierarchical traceback showing the entire stack of calling scripts and the last-executed lines within them.

If printing out the line number isn't easy to do, then just as good would be to print out the text of the most recent line or command that was parsed.  Presumably that text exists in some stack in Ferret?  Then the user could easily grep through their script to locate that line.

Andrew

On Tue, Jan 28, 2020 at 12:19 PM Ansley C. Manke <ansley.b.manke@xxxxxxxx> wrote:
Hi Marco

I like the idea of including the name of the script in error messages. 
I would make use of that.  I'm not sure whether also including the
line-number would be easy to implement but we'll have a look at these ideas.

Meanwhile a further tool is available for debugging.  Starting with
Ferret v6.9, redirect the output to a log file using SET REDIRECT.  Then
that log output includes lines that list entry and exit from scripts,
and the Unix tool FshowGO makes a listing of the go-script calls.  This
is discussed here:

https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/SET#_VPINDEXENTRY_SET_REDIRECT
https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/introduction/UNIX-TOOLS#_FshowGO

And one more thing:  if your set of  calls includes scripts that may
turn off mode verify, but you want to see the commands they run, start
the session with

SET MODE VERIFY:always

which causes any CANCEL MODE VERIFY commands to be ignored.

-Ansley


On 1/28/2020 1:09 AM, Marco van Hulten wrote:
> Ryo—
>
> On 28 Jan 11:46 Ryo Furue wrote:
>> On Mon, Jan 27, 2020 at 11:39 PM Marco van Hulten <Marco.Hulten@xxxxxx>
>> wrote:
>>
>>> When Ferret returns an error, is it possible to print the filename and
>>> linenumber of the GO script?
>>> [ . . . ]
>>> This is especially useful in my case where I am using jnl scripts that
>>> call other jnl scripts and so on.
>>>   
>> I would certainly appreciate such a feature.  But, with "set mode verify",
>> you can usually track down where the error is.
> Yes, that's true enough.  I now initialise a variable "verbosity" and
> then use this line at the start of my scripts:
>
>      \if `verbosity lt 2` then cancel mode verify else set mode verify
>
> and cancel at the end of the script.  That way VERIFY is disabled when
> back at the prompt.
>
> —Marco
>

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement