Currently I have an error handler that reports the error and details of it: logs some information regarding it (details, line number of the error, location *procedure name* of the error, operating system the error occurred on, date the error happened. The code I used to create this is listed below. After reading several articles on error trapping and logging I discovered one that suggested dumping all the active variables of the procedure and their values in the log as well. It seemed to indicate that there was a way to do this without searching through every procedure on every form and listing the variables manually for the log. So my question is is there a way to have my error handler when outputting simply stick in the names of the active variables and values without explicitly setting what variables it will write before hand? If further clarification is needed please let me know. Here's an example of what I want my log to look like.
In this example scenario the log created shows all relevant information including a list of active variables. Looking at the log if i know that variable 2 was suppose to be an integer I can tell clearly that this specifically was where the error was instigated.----------------------5gws V2 Error Log------------------------
Please report errors on the forums by copy pasting this log in
the trouble shooting section on the forums. These are found at
the following URL address:
http://www.blackdragongames.co.uk/fo...p?showforum=25
After posting feel free to delete the contents of this log
or simply delete the log file itself if you want.
----------------------5gws V2 Error Log------------------------
*********
5gws version 1.0
Error Details: Error #380 - Invalid property value! This error occurred in frmDatabaseWrestler.Loadwrestler on line #305.
OS Core: Windows_NT
Date of error: 4/12/2009 12:13:53 AM
~Active Variables~
ActiveVariableName1="ASDF THIS VARIABLE HAS STRING DATA"
ActiveVariableName2=ô╪'≡â*E
ActiveVariableName3=1345
*********
Here's what I have for error handling currently:
At the top of the form or module - Rename the "FORMNAME" with the name of the form or database
At the start of the procedure or function - Replace PROCEDURE_NAME witht he name of the procedure or funcitonCode:Private Const MODULE_NAME As String = "FORMNAME." '//For error trapping
At the end of the functionCode:'Set up Error handler. On Error GoTo handleError: Dim sErrorDescription As String Const sProcSig = MODULE_NAME & "PROCEDURE_NAME"
Error handler procedures in a moduleCode:'//Error trapping Exit Sub handleError: With Err sErrorDescription = "Error #" & .Number & " - " & _ .Description & "! This error occurred in " & sProcSig & _ IIf(Erl <> 0, " on line #" & CStr(Erl) & ".", ".") End With ErrorHandler sErrorDescription Resume Next '//Continue on the next line of code
Code:Public Sub ErrorHandler(sErrorDescription As String) Dim response As String response = MsgBox(sErrorDescription & vbCrLf & vbCrLf & " ~5gws will now create a log of this error in your 5gws directory for easy reporting. Code execution will continue on the next line of code. We highly recomend reporting the bug so it can get fixed and does not cause problems in yours or others database / game. Corrupted data can lead to an unusable save game.~", , App.Title & " Error") '//Create log file entry LogError sErrorDescription End SubCode:Public Sub LogError(Description As String) '//Dimension variables for use Dim ff As Integer Dim filepath As String '//Set variable inital values ff = FreeFile filepath = App.Path & "/ErrorLog.txt" '//create log file if it doesnt exist If Dir$(filepath) = "" Then Open filepath For Output As #ff Print #ff, "----------------------5gws V2 Error Log------------------------" Print #ff, "Please report errors on the forums by copy pasting this log in " Print #ff, "the trouble shooting section on the forums. These are found at " Print #ff, "the following URL address: " Print #ff, "http://www.blackdragongames.co.uk/forum/index.php?showforum=25 " Print #ff, "After posting feel free to delete the contents of this log " Print #ff, "or simply delete the log file itself if you want. " Print #ff, "----------------------5gws V2 Error Log------------------------" Print #ff, " " Print #ff, " " Close #ff End If ff = FreeFile Open filepath For Append As #ff Print #ff, "*********" Print #ff, "5gws version " & App.Major & "." & App.Minor Print #ff, "Error Details: " & Description Print #ff, "OS Core: " & Environ$("os") Print #ff, "Date of error: " & Now() Print #ff, "*********" Print #ff, " " Print #ff, " " Close #ff End Sub
Can anyone help this would be of massive help to me.




Reply With Quote