0

What are key words from throw exeption like this?

public void methodOne() throw SomeExeption {
     try{
         doSomething();
     catch(SomeExeption se) {
         throw se;
     }
}

public void startThere() {
   try{
       methodOne();
   catch(SomeExeption se) {
       Console.writeln("FAIL");
   }
}

I don't know, how to write it. I am getting syntax errors.

Thank you for your help.

  • 2
    You should see docs: [Creating and Throwing Exceptions (C# Programming Guide)](https://msdn.microsoft.com/en-us/library/ms173163.aspx) – Habib Sep 07 '16 at 14:05
  • The throw should be inside the body of the method. – Tom Biddulph Sep 07 '16 at 14:05
  • Even aside from the glaring syntax error in the first method (C# doesn't use checked exceptions like Java), *both* of these are examples of how ***not*** to handle exceptions. In both cases the code is ignoring useful exception information and artificially making it more difficult to correct the problem. – David Sep 07 '16 at 14:07

0 Answers0