For a very long time, when I have an error handler, I do this to report which project, module, and procedure were introduced. I always did this by simply storing their name through constants. I know that in the class you get the name programmatically using TypeName (Me), but obviously this gives me only one of the three pieces of information and only when I'm not in the standard module.
I donโt have a really huge problem with using constants, itโs just that people donโt always keep them up to date, or, even worse, they copy and paste, and then you report the wrong name, etc. So I would like to figure out how to get rid of the constants shown in the example without losing information.
Option Compare Binary
Option Explicit
Option Base 0
Option Private Module
Private Const m_strModuleName_c As String = "MyModule"
Private Sub Example()
Const strProcedureName_c As String = "Example"
On Error GoTo Err_Hnd
Exit_Proc:
On Error Resume Next
Exit Sub
Err_Hnd:
ErrorHandler.FormattedErrorMessage strProcedureName_c, m_strModuleName_c, _
Err.Description, Err.Source, Err.Number, Erl
Resume Exit_Proc
End Sub
- , , , ? , , :)
:
, Err.Source. . , , .
, , , , , Module.Procedure.