Use Exception.ToString() instead of Exception.Message.
2013-11-13 11:53
423 查看
Exception.Messagecontains 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).
相关文章推荐
- hive----MetaException(message:Could not connect to meta store using any of the URIs provided. Most r
- 【Robotframework】WebDriverException: Message: Expected [object Undefined] undefined to be a string
- When to Use Bar Charts Instead of Pie Charts
- org.json.JSONException: Value ok of type java.lang.String cannot be converted to JSONObject: [Caugh
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArra
- attempting to bokeyaunrun eclipse useing the jre instead of jdk,to run eclipse using
- When to Use Delegates Instead of Interfaces
- Use parameters instead of string concatenation for forming SQL queries,用参数方式来生成sql语句,而不是用连接字符串的方式
- DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command f
- When to Use Delegates Instead of Interfaces
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- How to use stringWithContentsOfURL:encoding:error:
- Use StringBuilder instead of String as possible as you can.
- How to use USB to do charger detection instead of PMIC?
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- 干活来袭:Effective Concurrency: Know When to Use an Active Object Instead of a Mutex
- myeclips报错:!MESSAGE Unhandled event loop exception !STACK 0 java.lang.OutOfMemoryError: unable to cr
- java.lang.RuntimeException: Value <pre>bool(false) of type java.lang.String cannot be converted to J
- Words to Use Instead of "Very"
- When to use Tomcat CATALINA_OPTS instead of JAVA_OPTS - See more at: http://www.tikalk.com/java/when