G
Guest
I have a sheet that has a general error handler that is called in the highest
procedure (the event handler in this case). I want to know if there is a way
to pass either a line # or a method name or even the control (since I have
checkboxes as well) that initiated the error. My general Error handler is
below and I use that to feed the info into an e-mail for the user to send to
me.
Also if I enact error_handling somewhere else in the code, to capture a
specific error, how do I ensure the remaining code is caught by the generic
error handler.
Obviously I miss my try/catch
Thanks for any help.
Private Sub btnAdd_Click()
On Error GoTo GEN_ERROR_HANDLER
Add_Row_To_Control
Exit Sub
GEN_ERROR_HANDLER:
Generic_Error_Handling
End Sub
'*****************************************************************************
'*Name: Generic_Error_Handling
'*Desc: Alerts user to error and safetly exists from all procedures
'*Input Parameters: NONE
'*
'*Returns: NONE
'*****************************************************************************
Sub Generic_Error_Handling()
'VAR
Dim sError As String
Dim strExplain As String
'BEGIN
'Build Error String
sError = "User: " & Environ("username") & Chr(10) & _
"An unexpected error has occured with the following properties:"
& Chr(10) & Chr(10) & _
"Description: " & Err.Description & Chr(10) & _
"Source: " '& strSource (removed until source can be ID'd)
'Alert User
strExplain = InputBox(sError & Chr(10) & Chr(10) & _
"An e-mail will be generated to be send an error report so this
issue can " & _
"be fixed.", "Describe Actions")
sError = sError & Chr(10) & _
"User Explanation: " & strExplain
'Activate the control sheet
gcwsControl.Activate
'Ensure Interactivity and Updating restored
ScreenUpdating True
'Create E-mail Alerting of problem
SendEmail "Streger, Jared M", "Error Log - " & gcwbThis.Name,
BodyText:=sError
End Sub
procedure (the event handler in this case). I want to know if there is a way
to pass either a line # or a method name or even the control (since I have
checkboxes as well) that initiated the error. My general Error handler is
below and I use that to feed the info into an e-mail for the user to send to
me.
Also if I enact error_handling somewhere else in the code, to capture a
specific error, how do I ensure the remaining code is caught by the generic
error handler.
Obviously I miss my try/catch
![Stick Out Tongue :P :P](/styles/default/custom/smilies/tongue.gif)
Private Sub btnAdd_Click()
On Error GoTo GEN_ERROR_HANDLER
Add_Row_To_Control
Exit Sub
GEN_ERROR_HANDLER:
Generic_Error_Handling
End Sub
'*****************************************************************************
'*Name: Generic_Error_Handling
'*Desc: Alerts user to error and safetly exists from all procedures
'*Input Parameters: NONE
'*
'*Returns: NONE
'*****************************************************************************
Sub Generic_Error_Handling()
'VAR
Dim sError As String
Dim strExplain As String
'BEGIN
'Build Error String
sError = "User: " & Environ("username") & Chr(10) & _
"An unexpected error has occured with the following properties:"
& Chr(10) & Chr(10) & _
"Description: " & Err.Description & Chr(10) & _
"Source: " '& strSource (removed until source can be ID'd)
'Alert User
strExplain = InputBox(sError & Chr(10) & Chr(10) & _
"An e-mail will be generated to be send an error report so this
issue can " & _
"be fixed.", "Describe Actions")
sError = sError & Chr(10) & _
"User Explanation: " & strExplain
'Activate the control sheet
gcwsControl.Activate
'Ensure Interactivity and Updating restored
ScreenUpdating True
'Create E-mail Alerting of problem
SendEmail "Streger, Jared M", "Error Log - " & gcwbThis.Name,
BodyText:=sError
End Sub