Thanks kent.
I am looking for something like this. Say I have a script something like this,

# example.py
abortOnError=1 # this is a global variable
print 'Executing example'
print 'Now this will raise a NameError '+notDefined
print 'Continue execution ... '
print 'end of script'

This simple script raises a NameError for 'notDefined' since that variable is not defined. I would like this script not to abort execution even if any error is raised and continue to the next line (since the user defined abortOnError=1). I initially thought this could be achieved by defining a custom exceptionhook, but that did not solve my problem.

Thanks for any help,
-satya

Kent Johnson wrote:
Sure. Is this what you mean? 

Jython 2.1 on java1.4.2_03 (JIT: null)
Type "copyright", "credits" or "license" for more information.
  
def raiser():
        
...   raise NotImplementedError
...
  
def catcher():
        
...     try:
...             raiser()
...     except:
...             if exception_aborts:
...                     print 'propagating exception'
...                     raise
...             else:
...                     print 'logging exception'
...                     import traceback
...                     traceback.print_exc()
...
  
exception_aborts=1
catcher()
        
propagating exception
Traceback (innermost last):
  File "<console>", line 1, in ?
  File "<console>", line 7, in catcher
  File "<console>", line 2, in raiser
NotImplementedError:
  
exception_aborts=0
catcher()
        
logging exception
Traceback (most recent call last):
  File "<console>", line 2, in raiser
NotImplementedError
  

Kent

  
From: Satya Ghattu <sghattu@bea.com>
Date: 2004/03/07 Sun PM 07:31:51 EST
To: jython-users@lists.sourceforge.net
Subject: [Jython-users] continue script execution in case of error

While running a script if an error / exception is raised, depending on a 
variable setting i would like to stop the execution of the script or 
print the error and continue with the script execution.
Is there a way to do this?

Thanks,
-satya



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

    



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users