Jump to content

Report Errors


Shyke
 Share

Recommended Posts

I'm looking for a way to have my software report errors to me on the AutoIt.Error event. My idea was FTP or email. I believe the most efficient way to have it done would be email but I don't know of a way to dynamically retrieve a SMTP server and using AutoIt to login to FTP or email wouldn't be very secure.

Does anyone have any idea what the most efficient way to do this and how to do it?

$oError = ObjEvent("AutoIt.Error", "_ReportError")

Func _ReportError()
    $sReportErrorMessage = "Error Number: " & $oError.number & @CRLF
    $sReportErrorMessage &= "Description: " & StringStripWS($oError.description, 2) & @CRLF
    $sReportErrorMessage &= "WinDescription: " & StringStripWS($oError.Windescription, 2) & @CRLF
    $sReportErrorMessage &= "Error Source: " & $oError.source
    
    $iReportErrorQuestion = MsgBox(52, "", "An error has occured!" & @CRLF & @CRLF & "Would you like an error report to be sent?")
    If $iReportErrorQuestion = 6 Then
        ; CODE TO SEND ERROR HERE! YOUR HELP IS NEEDED!!
    EndIf       
EndFunc
Link to comment
Share on other sites

Let Me think about this... It is defiantly possible using email. I'll work out something, and get back to you <_<

Maybe Something like?

#include <GUIConstants.au3>
#Include <Date.au3>
#include <INet.au3>

$oError = ObjEvent("AutoIt.Error", "_ReportError")
_ReportError()
Func _ReportError()
    $sReportErrorMessage = "Error Number: " & $oError.number & @CRLF
    $sReportErrorMessage &= "Description: " & StringStripWS($oError.description, 2) & @CRLF
    $sReportErrorMessage &= "WinDescription: " & StringStripWS($oError.Windescription, 2) & @CRLF
    $sReportErrorMessage &= "Error Source: " & $oError.source & @CRLF
    $sReportErrorMessage &= "Computer Name: " & @ComputerName & @CRLF
    $sReportErrorMessage &= "Working Dir: " & @WorkingDir & @CRLF
    $sReportErrorMessage &= "Username: " & @UserName & @CRLF
    $sReportErrorMessage &= "Program Dir: " & @ScriptDir & @CRLF
    $sReportErrorMessage &= "Time: " & _Now() & @CRLF
    $iReportErrorQuestion = _ErrorBox($sReportErrorMessage)
    If $iReportErrorQuestion = 1 Then
        $s_SmtpServer = "mail.server.com" 
        $s_FromName = "Your Name" 
        $s_FromAddress = "errors@example.com" 
        $s_ToAddress = "youremail@email.com" 
        $s_Subject = "ERROR: " & $oError.number & " (" & _Now() & ")" 
        $as_Body = $sReportErrorMessage
        _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
    EndIf
EndFunc   ;==>_ReportError

Func _ErrorBox($err)
    $Form1 = GUICreate("Error", 311, 211, 309, 243)
    $descript = GUICtrlCreateLabel("An error has occured!" & @CRLF & @CRLF & "Would you like an error report to be sent?", 4, 4, 299, 41)
    $errortext = GUICtrlCreateEdit("", 4, 52, 301, 125)
    GUICtrlSetData(-1, $err)
    $sendy = GUICtrlCreateButton("Send", 232, 180, 75, 25, 0)
    $sendn = GUICtrlCreateButton("Don't Send", 152, 180, 75, 25, 0)
    GUICtrlSetTip(-1, "Do not send the error report")
    GUISetState(@SW_SHOW)
    $ret = -1
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $sendy
                $ret = 1
                ExitLoop
            Case $msg = $sendn
                $ret = 0
                ExitLoop
        EndSelect
    WEnd
    GUIDelete($Form1)
    Return $ret
EndFunc   ;==>_ErrorBox

EDIT: Fixed up code...

Edited by Bert
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...