“抛出'System.Exception'类型的异常”的措辞从何而来?

Ric*_*unt 1 .net c#

我正在处理一个复杂的应用程序,它有时会在我们的日志文件中产生以下内容:

Exception of type 'System.Exception' was thrown
Run Code Online (Sandbox Code Playgroud)

我可以找到异常的原因,但我的问题是文本的确切措辞来自哪里。

单词Exception of typeandwas thrown不在我们的应用程序中,但会出现在 google 搜索各种应用程序中,因此必须有一个系统组件将这些文本放在一起。

这不是ToString()异常对象的标准,如果我编写一个只是抛出的应用程序,应用程序的命令行输出不包含该文本。

感觉就像一些标准组件正在捕获底层异常并在添加这些词的情况下重新抛出它。如果我知道发生了什么,那么追踪潜在问题的原因就会容易得多。

有任何想法吗?

dxi*_*xiv 6

Exception of type 'System.Exception' was thrown.是默认值System.Exception.Message

dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Exception.cs

public virtual string Message => _message ?? SR.Format(SR.Exception_WasThrown, GetClassName());
Run Code Online (Sandbox Code Playgroud)

dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

<data name="Exception_WasThrown" xml:space="preserve">
  <value>Exception of type '{0}' was thrown.</value>
</data>
Run Code Online (Sandbox Code Playgroud)