Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module PublicFuncs
- <Runtime.InteropServices.ComVisible(False)>
- Public Sub PushTheStack(ByVal ex As Exception) ':)
- Dim Result As String = String.Empty
- Dim hr As Integer = Runtime.InteropServices.Marshal.GetHRForException(ex)
- 'debug normal:
- Result = ex.GetType.ToString & "(0x" & hr.ToString("X8") & "): " & ex.Message & Environment.NewLine & ex.StackTrace & Environment.NewLine
- Dim st As StackTrace = New StackTrace(ex, True)
- For Each sf As StackFrame In st.GetFrames
- If sf.GetFileLineNumber() > 0 Then
- Result &= "Linha número " & sf.GetFileLineNumber() & " no ficheiro: `" & IO.Path.GetFileNameWithoutExtension(sf.GetFileName) & "´ com o método `" & IO.Path.GetFileNameWithoutExtension(sf.GetMethod.Name) & "´ provocou um erro: "
- End If
- Next
- writeDebug("TRACE: " & Result & ex.Message)
- End Sub
- <Runtime.InteropServices.ComVisible(False)> _
- Public Sub writeDebug(ByVal __text As String)
- Try
- Console.WriteLine(__text)
- Dim objWriter As New System.IO.StreamWriter(Today.ToString("yyyy-MM-dd") & ".log", True)
- objWriter.WriteLine(Now.ToString("yyyy-MM-dd HH:mm:ss") & vbTab & __text)
- objWriter.Close()
- Catch ex As Exception
- '
- End Try
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement