[Thread Prev][Thread Next][Index]

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



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