Exception.Message vs Exception.ToString()

I have code that is logging Exception.Message. However, I read an article which states that it’s better to use Exception.ToString(). With the latter, you retain more crucial information about the error. Is this true, and is it safe to go ahead and replace all code logging Exception.Message? I’m also using an XML based layout for … Read more

When should I use Debug.Assert()?

I’ve been a professional software engineer for about a year now, having graduated with a CS degree. I’ve known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains no asserts whatsoever and my question is this… Should … Read more

e.printStackTrace equivalent in python

I know that print(e) (where e is an Exception) prints the occurred exception but, I was trying to find the python equivalent of Java’s e.printStackTrace() that exactly traces the exception to what line it occurred and prints the entire trace of it. Could anyone please tell me the equivalent of e.printStackTrace() in Python? 4 Answers … Read more

How do you implement a re-try-catch?

Try-catch is meant to help in the exception handling. This means somehow that it will help our system to be more robust: try to recover from an unexpected event. We suspect something might happen when executing and instruction (sending a message), so it gets enclosed in the try. If that something nearly unexpected happens, we … Read more

How do I create a custom Error in JavaScript?

For some reason it looks like constructor delegation doesn’t work in the following snippet: function NotImplementedError() { Error.apply(this, arguments); } NotImplementedError.prototype = new Error(); var nie = new NotImplementedError(“some message”); console.log(“The message is: ‘”+nie.message+”‘”) Running this gives The message is: ”. Any ideas as to why, or if there is a better way to create … Read more