Trying to replace "On Error Goto Err_SomeFunction" with "On Error Goto Error_In_Code" (1 Viewer)

essaytee

Need a good one-liner.
Local time
Today, 19:11
Joined
Oct 20, 2008
Messages
546
Ok, I first went the ChapGPT route for the solution but I haven't got it working. What I want to do is replace all my error handling routines with standard code snippets. For some of my functions, across many modules, I have "On Error Goto Err_SomeFunctionName" and I have the corresponding label towards the end of the function "Err_SomeFunctionName:" I want to replace with "On Error Goto Error_In_Code" and the label to be "Error_In_Code:"

For what it's worth, here's a link to my ChatGPT back'n'forth.

From ChatGPT I got it as far as the code matching "On Error Goto Err_SomeFunction" but that portion of code was within a commented out line, but it didn't recognise the true code at the top of the function, not indented and not commented out.

Here is the reg ex that that I finally got to:

Code:
    re.Pattern = "On\s+Error\s+Goto\s+Err_\w+"

Any suggestions?
 
Is the "Error_In_Code" label going to be local to the routine that incurs the error? If not, you might not be able to dismiss the error with a "Resume Next" even when such resumption would be appropriate.

What I did was I always allowed the Access event routine wizards to build a "stub" that was essentially a MsgBox response that identified the error and allowed me to do an OK_Only response, then the code did a Resume Next for me. But I replaced the stub with a call to a routine that did error logging in an event file and that way, I knew I had uniform error reporting. But that automatic dismissal ("Resume Next") wasn't always appropriate. You do you, of course. It was my finding that logging could be "farmed out" to a common logging routine but actual handing of the error needed to be local to that module if there was ANY special handling to be done.
 
Yes, the "Error_In_Code" label is local to the function or procedure. I've only specified half the issue of standardising the error handling routine. Yes, I will be addressing the other half. I also have when in the error stub, "Resume Exit_ErrSomeFunctionName" and that will be replaced with "Resume Exit_Code", and therefore will be replacing "Exit_Err_SomeFunctionName:" with "Exit_Code:" So at this point I don't understand why reg ex is not replacing the "On Error...." part. My error handling stubs moving forward are standardised.
 

Users who are viewing this thread

Back
Top Bottom