comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Error handling and tracebacks
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Error handling and tracebacks [message #40112] Wed, 21 July 2004 22:08
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> In short, I thought I might rid myself of this dilemma if I could
> somehow show them the error message with no trace. This is more
> *normal* to them and as such they'd actually *read* the error message
> like they should have in the first place.

Well, heck, something like this will work then:

Catch, theError
IF theError NE 0 THEN BEGIN
Print, !Error_State.Msg
RETURN
ENDIF

Now, throw the error with Message:

Message, 'Whoops! Did you read the docs?'

You get something like this:

%YourProgram: Whoops! Did you read the docs?

That's about as simple as it gets. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Error handling and tracebacks [message #40114 is a reply to message #40112] Wed, 21 July 2004 21:52 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
>> How do I disable tracebacks associated with the message procedure?
>
>
> My goodness, you are having a tough day, today. :-)
>

It's not very often you get two IDL questions from completely different
ends of the spectrum at the same time on the same day, but it happens.
Oh, well. Part of the business, I suppose. :-)

> I think your only hope here is to CATCH the errors
> thrown by MESSAGE yourself, then prune the error traceback
> (which you maybe save in a string variable, with the OUTPUT
> keyword) and pass it on to the user:
>
> Catch, theError
> IF theErron NE 0 THEN BEGIN
> Help, /Traceback, Output=helpString
> Prune, helpString
> Print, helpString
> ENDIF

I played with catching the error some, but I really didn't like results
too much. I just don't have enough time to play with things. Really,
the problem is of no concern to me, but it seems that I'm going to have
to go on an end user education project. The problem is that some people
using my stuff are too quick to think that a bug has come up in my code.
When they see the traceback, 9 times out of 10, they don't even look
at the message I put out at the top because they think that some crazy
bug caused something screwy to happen. (Almost all of my IDL programs
are on the command line, BTW) Invariably, they have simply mistyped
something in the call into my code.

In short, I thought I might rid myself of this dilemma if I could
somehow show them the error message with no trace. This is more
*normal* to them and as such they'd actually *read* the error message
like they should have in the first place.

Sigh.

> I don't have any idea what the PRUNE procedure
> might look like. :-(

Might it look like the PLUM procedure after having sat out in the sun
too long?

-Mike
Re: Error handling and tracebacks [message #40117 is a reply to message #40114] Wed, 21 July 2004 16:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> How do I disable tracebacks associated with the message procedure?

My goodness, you are having a tough day, today. :-)

> Before the programming gurus yell at me for potentially hiding bugs my
> code, let me explain why I want to do this. I have a library of
> procedures and in certain cases I am creating my own errors via message
> which are several calls down in the stack. When the error comes out,
> there is a long traceback, but I only want the end user to see the
> message itself and not the entire traceback since the traceback is going
> several layers down into code that the end user shouldn't even be aware
> of. I do want the user to see the error, but not all the files and line
> numbers.

I think your only hope here is to CATCH the errors
thrown by MESSAGE yourself, then prune the error traceback
(which you maybe save in a string variable, with the OUTPUT
keyword) and pass it on to the user:

Catch, theError
IF theErron NE 0 THEN BEGIN
Help, /Traceback, Output=helpString
Prune, helpString
Print, helpString
ENDIF

I don't have any idea what the PRUNE procedure
might look like. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Error handling and tracebacks
Next Topic: ENVI: auto_wid_mng

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:07:37 PDT 2025

Total time taken to generate the page: 0.00231 seconds