![]() |
| ||
| Error trapping while reading windows XP registry entries I ran the following program to retrieve entries from the windows registry on Windows XP: import win32api, win32conProgram output: Quote:
import win32api, win32con, sysProgram output: Quote:
What code is needed to specifically trap the "no more data is available" error? Thank you in advance for your help! |
| ||
| Re: Error trapping while reading windows XP registry entries Here is an example error: >>> List = ['item1','item2','item3']if you look at the traceback bit it tells you some useful information, including the error type which in this case is: IndexError Now all you have to do is include the error type with the except function: >>> List = ['item1','item2','item3']as you can see, the new part of the except command, catches the IndexError and does something about it other than killing the program. you can have more than one except command too, for example if you wanted to catch a few different types of errors: >>> for item in range(10): In your case you need to have 'error' after the except followed by the details within the error, which is the section in brackets: except: error (259, 'PyRegEnumValue', 'No more data is available.') Just shout if you need anymore help, a1eio P.S I'm not on my normal computer so i can't test the above theory with win32api if it doesn't work, just reply with the reason why and i'll fix it. in the meantime i'm trying to get win32api but www.python.net doesn't seem to be responding at the moment. |
| ||
| Re: Error trapping while reading windows XP registry entries Ok, I got my hands on win32api, and i've had a little play with your code, and it turns out what i said: Quote:
import win32api, win32con, sysThe output: Quote:
the information after ANY error can be caught by attaching a variable to the end of an except command, after a comma eg: except: ErrorType, VariableName: then you can handle the contents of the variable as if it were any other, eg: print VariableName in the example above, i've checked the variable 'details' for the error type '259' which is win32api's way of saying no more data is available. any problems, just say. a1eio |
| All times are GMT -4. The time now is 10:31 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC