c# - What is the best practice for capturing all inner exception details? -
this question has answer here:
what best practice logging complete exception details including possible inner exceptions?
currently, use following code:
try { //some code throws exception } catch(exception ex) { { console.writeline(ex.message+ex.stacktrace); ex=ex.innerexception; }while(ex!=null) }
are there scenarios code may fail?
have tried using ex.tostring()
? gives (if not all) of data need diagnose - including message details, stack trace, , inner exceptions:
from msdn:
tostring returns representation of current exception intended understood humans. exception contains culture-sensitive data, string representation returned tostring required take account current system culture. although there no exact requirements format of returned string, should attempt reflect value of object perceived user. default implementation of tostring obtains name of class threw current exception, message, result of calling tostring on inner exception, , result of calling environment.stacktrace. if of these members null, value not included in returned string.
Comments
Post a Comment