We help IT Professionals succeed at work.
Get Started

Exception handling - VB.net

690 Views
Last Modified: 2012-08-12
I'm trying to figure out how to improve my exception handling in VB.net.

Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click
  1: Try
  2:   Code......
  3:   ...............
  4:   Call MyTestProc
  5:   ................
  6:   ..................
  7: Catch ex As Exception
  8:   Call MyReportError(ex, "frmMain", "cmdTest_Click")
End Sub

Privat sub MyTestProc()
   9: Try
  10:   Code......
  11:   ...............
  12:   ..............
  13:   ................
  14:   ..................
  15: Catch ex As Exception
  16:   Call MyReportError(ex, "frmMain", "MyTestProc")
End Sub

  Friend Sub MyReportError(ByVal ex As Exception, ByVal sClass As String, ByVal sProc As String)
    '''HERE I JUST WRITE A LOG FILE, WITH ALL THE ERROR DESCRIPTION, ERR NUMBER, LINE NUMBER, ETC AND SEND IT TO ME IF THE USER WANTS TO REPORT THE ERROR.
  End Sub

Open in new window


If there is an error on line 13 for example then the error report log file says, error on line 4.
My question is how would I get the real error line (line 13) in my log file and possible the Call stack where it originates from?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 3 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE