Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send detailed error info in email

Status
Not open for further replies.

circlemaker

Programmer
Aug 24, 2004
6
0
0
GB
Hello,

Does anyone know if its possible to send the page error message i.e.

---------------
Server Error in '/test1' Application.

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The Runat attribute must have the value Server.

Source Error:

etc etc...
---------------

in an email. I would like to both handle the error so the user sees a friendly page and send the detailed error to myself in an email so I can immediately see what the problem is.

Thanks for any advice

Simon
 
Yes, if you have caught the error simply use ex.Message and insert that into the body of your email.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Here's what I email to the helpdesk...i send this function the Exception that my try/catch gets...

basically it checks an application setting to see if it should be sending emails, if yes, then send an HTML formatted error message...

Code:
  Public Class CaughtError
    Public Sub showMeTheError(ByVal xXx As Exception)
      If xXx.Message.ToString = "Thread was being aborted." Then
        Exit Sub
      End If
      If CBool(ConfigurationSettings.AppSettings("sendEmails")) = True Then
        Dim str As New StringBuilder
        str.Append("<strong>Please contact IT Development regarding this error.<strong><br><br><TABLE id='tbl' style='HEIGHT: 358px' borderColor='#990000' cellSpacing='1' cellPadding='1' width='600' border='1'>")
        str.Append("<TR><TD style='COLOR: white' bgColor='#990000'>Error Tracking Message: Task List</TD>")
        str.Append("</TR><TR><TD><TABLE id='Table1' style='WIDTH: 592px; HEIGHT: 307px' cellSpacing='1' cellPadding='1'")
        str.Append("width='592' border='0'><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>User:</STRONG></TD><TD vAlign='top'>")
        str.Append(Current.Request.Cookies("TPLATE")("NAME").ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Email:</STRONG></TD>")
        str.Append("<TD vAlign='top'><A href='mailto:")
        str.Append(Current.Request.Cookies("TPLATE")("UID"))
        str.Append("@virchowkrause.com'>Email User</A></TD></TR><TR>")
        str.Append("<TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Error Message:</STRONG></TD><TD vAlign='top'>")
        str.Append(xXx.Message.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Source:</STRONG></TD><TD vAlign='top'>")
        str.Append(xXx.Source.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Stack Trace:</STRONG></TD><TD vAlign='top'>")
        str.Append(xXx.StackTrace.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>URL:</STRONG></TD><TD vAlign='top'>")
        str.Append(Current.Request.RawUrl.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Date/Time:</STRONG></TD>")
        str.Append("<TD vAlign='top'>" & Date.Now.ToString & "</TD></TR></TABLE></TD></TR></TABLE>")

        Dim status As String
        Dim email As New workflowMailer
        email.toAddresses = ConfigurationSettings.AppSettings("HelpDeskEmail")
        email.subject = "VK Forms Error Notification from " & Current.Request.Cookies("TPLATE")("NAME")
        email.body = str.ToString
        email.sendMail()
        email.Dispose()
        email = Nothing
        Current.Response.Redirect("../../teamplateforms.net/workflowhome/vkerror.aspx")
      Else
        Dim str As New StringBuilder
        str.Append("<strong>Please contact IT Development regarding this error.<strong><br><br><TABLE id='tbl' style='HEIGHT: 358px' borderColor='#990000' cellSpacing='1' cellPadding='1' width='600' border='1'>")
        str.Append("<TR><TD style='COLOR: white' bgColor='#990000'>Error Tracking Message: Task List</TD>")
        str.Append("</TR><TR><TD><TABLE id='Table1' style='WIDTH: 592px; HEIGHT: 307px' cellSpacing='1' cellPadding='1'")
        str.Append("width='592' border='0'><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>User:</STRONG></TD><TD vAlign='top'>")
        str.Append(Current.Request.Cookies("TPLATE")("NAME").ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Email:</STRONG></TD>")
        str.Append("<TD vAlign='top'><A href='mailto:")
        str.Append(Current.Request.Cookies("TPLATE")("UID"))
        str.Append("@virchowkrause.com'>Email User</A></TD></TR><TR>")
        str.Append("<TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Error Message:</STRONG></TD><TD vAlign='top'>")
        str.Append(xXx.Message.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Source:</STRONG></TD><TD vAlign='top'>")
        str.Append(xXx.Source.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Stack Trace:</STRONG></TD><TD vAlign='top'>")
        str.Append(xXx.StackTrace.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>URL:</STRONG></TD><TD vAlign='top'>")
        str.Append(Current.Request.RawUrl.ToString)
        str.Append("</TD></TR><TR><TD style='WIDTH: 120px' vAlign='top' align='left'><STRONG>Date/Time:</STRONG></TD>")
        str.Append("<TD vAlign='top'>" & Date.Now.ToString & "</TD></TR></TABLE></TD></TR></TABLE>")
        Current.Response.Write(str.ToString)
        Current.Response.End()
      End If
    End Sub
  End Class

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top