Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




Tip 9: Trace the stack

software


Tip 9: Trace the stack.

As you saw in the log file in Listing 1-3, we dump the VBA call stack when we hit an unexpected error because it can be useful for working out later what went wrong and why. We build an inter 15215k1017p nal representation of VBA's stack (because VBA's stack is not actually available-shame), using two fundamental routines: TrTraceIn and TrTraceOut. Here they are in a typical routine:



Public Sub Testing()

' Set up general error handler.
On Error GoTo Error_General_Testing:
Const sProcSig = MODULE & " General.Testing"
Call TrTraceIn(sProcSig)

========= Body Code Starts ==========
.
.
.

========= Body Code Ends ==========

Call TrTraceOut(sProcSig)
Exit Sub

' Error handler.
Error_General_Testing:
.
.
.

End Sub

These routines are inserted by hand or by using the same internal tool I mentioned earlier in Tip 2 that adds line numbers to code. Notice that sProcSig is being passed into these routines so that the stack can be built containing the name of the module and the routine.

The stack frame object we use internally (not shown here) uses a Visual Basic collection with a class wrapper for its implementation. The class name we use is CStackFrame. As a prefix, C means class, and its single instance is named oStackFrame. We drop the o prefix if we're replacing a standard class such as Err or App.


Document Info


Accesari: 1244
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )