Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does System.Exception have a built-in thrown timestamp?

Is there a way to extract when an exception was thrown from the exception itself, or will I need to manually add this information to the exception?

like image 300
mola Avatar asked Feb 17 '23 06:02

mola


1 Answers

There is no built-in Timestamp property for the Exception object. You can create a new class that inherits from Exception and add your own property.

If you're using your exception as a parameter of a log framework, you might want to handle the timestamp directly in the log framework (most probably using DateTime.Now / UtcNow).

like image 177
ken2k Avatar answered Feb 20 '23 02:02

ken2k