空StackTrace的异常

时间:2016-02-19 18:09:41

标签: vb.net exception stack-trace

我们有一种方法可以报告意外错误。

我们的处理代码(vb.net 4.0):

    Private paUnhandledException As Exception

    Private Function GetMessage(Detailed As Boolean) As String
        Dim stackMsg, msg As String
        Dim ex As Exception = Me.paUnhandledException

        If Detailed Then
            stackMsg = ex.ToString()
        ElseIf (Not String.IsNullOrEmpty(ex.StackTrace)) Then
            stackMsg = ex.StackTrace
            Dim l As Integer = 0
            Try
                l = stackMsg.IndexOf(System.Environment.NewLine)
                If l > 0 Then
                    l = stackMsg.IndexOf(System.Environment.NewLine, l + 1)
                End If
                If l > 0 Then
                    l = stackMsg.IndexOf(System.Environment.NewLine, l + 1)
                End If
            Catch
                l = -1
            End Try
            If l > 0 Then
                stackMsg = stackMsg.Substring(0, l - 1)
            End If
        Else
            stackMsg = ex.ToString
        End If

        msg = String.Format("{1}{2}",ex.Message, stackMsg)
        Return msg
    End Function

通常我们会收到类似的报告:

  

动态SQL错误SQL错误代码= -206列未知   PRINTING.INACTIVE在第1行,第688栏

     

FirebirdSql.Data.FirebirdClient.FbException(0x80004005):动态SQL   错误SQL错误代码= -206列未知PRINTING.INACTIVE在行   1,专栏688 --->动态SQL错误SQL错误代码= -206列   未知PRINTING.INACTIVE在第1行,第688行   FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(的CommandBehavior   行为)   FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(的CommandBehavior   行为)   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(的CommandBehavior   行为)

我们收到了以下报告:

  

动态SQL错误SQL错误代码= -104以字符串常量分隔   用双引号

     

动态SQL错误SQL错误代码= -104以字符串常量分隔   用双引号

问题 - 没有堆栈跟踪。

我做过一些研究,阅读论坛,偶然发现了这些帖子:exception with no stack trace - how?Empty StackTrace. Possible?

异常本身不是NULL,因为我们从ex.Message获取文本。如果重新抛出异常,即使在这种情况下,堆栈跟踪中至少会有一行 - 从重新抛出的位置开始。如果异常源自另一个线程,则类似。我不认为它与我们使用的数据库系统有关 - Firebird。 我几乎没有可能发生空堆栈跟踪的可能性:

  • OutOfMemory - 程序以某种方式进入OOM,因此没有堆栈跟踪
  • .toString
  • 的例外情况

到目前为止,我们还不知道如何模拟此错误,也无法从发起的机器访问EventLog。

对我的假设有任何更正?我错过了什么? 提前谢谢。

0 个答案:

没有答案
相关问题