Re: Resuming a program's execution after correcting error



Georg Brandl wrote:
As I said before, this can be done by finding out where the error is raised,
what the cause is and by inserting an appropriate try-except-statement in
the code.

I could be mistaken, but I *think* the OP is asking how to re-enter the
stack at the same point as the exception exited from and continue with
the execution as if the exception never happened. AFAIK, that isn't
possible; however, given that he has a file to work from that indicates
a portion of the state at the time of the exception, I think he may be
able simulate that kind of functionality by reading in the file on
exception and then returning a call to the function where the exception
occured with the data from the file. Something like this mockup:

def faulty_function(a, b, c=None):
if not c:
c = 0
try:
# modify c, write c to file...
# oops hit an exception
c += a / b
except:
# read from the file here
# c = ...
# and fix the error
b += 1
return faulty_function(a, b, c)
return c

print faulty_function(2, 0) # => 2

Of course, it's probably much better to just fix the code and avoid the
exception in the first place. ;)

Regards,
Jordan

.



Relevant Pages

  • Re: Very strange "input string not in correct format" bug
    ... the trick of changing locale to something else and then back again did ... I hope Microsoft can eventually find and fix this! ... I tried to reproduce the exception by setting the thread culture to all ... cultures are the UI cultures but, I'd rather check first what are the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Checking for null parameter
    ... it throw a checked exception? ... How can you fix what you can't detect? ... before calling a method? ... Isn't this the same thing as if a NPE was thrown? ...
    (comp.lang.java.programmer)
  • RE: CheckSuspiciousPhysicalPath issue in ASP.Net Framework 1.1 SP1 fix
    ... This fix is included ... An unhandled exception occurred during the execution of the ... > current web request. ... > Char[] whitespaceChars, Char directorySeparator, Char altDirectorySeparator, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Exceptions RPC_S_UNKNOWN_IF
    ... closer to actual release, I'm trying to weed out all of the bugs that I can ... But would like an actual fix... ... Is this exception only happen after ever few thousand ... >>> Arkady ...
    (microsoft.public.win32.programmer.networks)
  • Re: Cannot add user to WSS3
    ... Even if the fix is tedious, ... is to stsadm -o export each site, sub site and sub sub site and so on, ... Delphi Technology Solutions ... Exception Occurred. ...
    (microsoft.public.sharepoint.windowsservices)