Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Do you raise or throw an exception?

I know that this probably doesn't really matter, but I would like to know what is correct.

If a piece of code contains some version of throw new SomeKindOfException(). Do we say that this piece of code can potentially raise an exception? Or throw an exception?

The keyword is throw, so I am kind of leaning towards that, but to raise an exception is also used a lot...

Do they have some sort of different meaning? Does one of them sort of implicate a difference over the other? Or is it just two words meaning exactly the same thing?

like image 714
Svish Avatar asked Jun 12 '09 09:06

Svish


1 Answers

In C# terminology, raising is used in the context of events and throwing is used in the context of exceptions.

Personally, I think throw/catch combination is more beautiful than raise/catch.

like image 58
mmx Avatar answered Oct 10 '22 20:10

mmx