You must log in or register to comment.
In Java you would say “throw e;” (to rethrow the same exception you just caught.)
You wouldn’t just say “throw”
Or you could also throw some other exception. But the syntax requires you specify what it is you are throwing. (And sane in C++, where you could throw any object, even a primitive.)
So that was my question.
Wildly, in C# you can do either and it has different results. I believe a bare
throw
doesn’t append to the stack trace, it keeps the original trace intact, whilethrow e
updates the stack trace (stored on the exception object) with the catch and rethrow.In C#, you can only throw objects whose class derives from Exception.