Java Nested try catch block unreachable issues -


here part of code...when want compile shows unreachable catch block selfdefineexception. exception never thrown try statement body

how can fix it, can me, cuz have tried million times solve

    try     {         statement 1;         statement 1;         statement 1;         statement 1;          try         {            statement 3;         }         catch (selfdefineexception er)         {             string error = er.getmessage();              system.out.print("issue: \n\t(" +er.getmessage() + ")");                 result = false;             }         }     }     catch (selfdefineexception er)     {         system.out.print("failed: " + er.getmessage());     } 

if selfdefineexception checked exception (which is, unless extending runtimeexception), should catch or declare (http://docs.oracle.com/javase/tutorial/essential/exceptions/catchordeclare.html). there 3 possible scenarios may give "unreachable code" here:

  1. if statement 3 1 calls method throws selfdefineexception, second catch unreachable, statements above can't throw that.
  2. if statement 3 doesn't contain call method throws selfdefineexception, first catch unreachable.
  3. if none contain calls methods declare "throws selfdefineexception" in method definition, both catch blocks unreachable.

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -