zoukankan      html  css  js  c++  java
  • Use Exception.ToString() instead of Exception.Message.

    Exception.Message contains only the message (doh) associated with the exception. Example:

    Object reference not set to an instance of an object

    The Exception.ToString() method will give a much more verbose output, containing the exception type, the message (from before), a stack trace, and all of these things again for nested/inner exceptions. More precisely, the method returns the following:

    ToString returns a representation of the current exception that is intended to be understood by humans. Where the exception contains culture-sensitive data, the string representation returned by ToString is required to take into account the current system culture. Although there are no exact requirements for the format of the returned string, it should attempt to reflect the value of the object as perceived by the user.

    The default implementation of ToString obtains the name of the class that threw the current exception, the message, the result of calling ToString on the inner exception, and the result of calling Environment.StackTrace. If any of these members is a null reference (Nothing in Visual Basic), its value is not included in the returned string.

    If there is no error message or if it is an empty string (""), then no error message is returned. The name of the inner exception and the stack trace are returned only if they are not a null reference (Nothing in Visual Basic).

  • 相关阅读:
    Emacs for OIer 的一些配置
    CF1336E Chiori and Doll Picking 【线性代数,组合计数】
    CF605E Intergalaxy Trips 【贪心,动态规划,期望】
    Luogu6329 【模板】点分树 | 震波
    [SDOI2014]数表
    [BZOJ4403]序列统计
    [BZOJ5099]Pionek
    SP1812 LCS2
    SA & SAM
    [HAOI2016]找相同字符
  • 原文地址:https://www.cnblogs.com/fdyang/p/3421116.html
Copyright © 2011-2022 走看看