Reading in external file - error checking and line numbers...

Hugh Macdonald hugh.macdonald at gmail.com
Wed Sep 7 05:58:54 EDT 2005


Thankyou! That was much easier than I expected.....

One more thing on a similar note..... When raising exceptions, is it
possible to remove a few items from the top of the stack trace?

My stack trace is looking something like:

  File "ripple", line 160, in ?
  File "ripple", line 94, in executeRipple
  File "test.rip", line 8, in ?
    dependsOnFrame = new)
  File "ripple", line 133, in __init__
  File "ripple", line 148, in addDependsOnFrame
__main__.RippleError: 'Cannot add frame dependency to non frame-based
node'

I'd like to be able to remove the last two items in the stack so that
it just shows the user:

  File "ripple", line 160, in ?
  File "ripple", line 94, in executeRipple
  File "test.rip", line 8, in ?
    dependsOnFrame = new)
__main__.RippleError: 'Cannot add frame dependency to non frame-based
node'

Unfortunately, I don't know how many 'ripple' stack items there will
be...

This is why I'd much rather, if I can, do this without exceptions and
just be able to print out my own error message with the problem line
number marked....

Or am I asking too much? ;)

--
Hugh Macdonald




More information about the Python-list mailing list