JSP: Création d’une classe de gestion d’exception personnalisée

Author:
       


    
        Creating a Custom Exception Object
    

    
        

Creating a Custom Exception Object

        <%!             class NewException extends Exception              {                 int value;                 public String toString()                  {                     return "NewException " + value;                 }                 NewException(int v)                  {                     value = v;                 }             }             void doWork(int value) throws NewException              {                 if(value == 0){                     throw new NewException(value);             }         }     %>     <%         try {             doWork(3);             doWork(0);         } catch (NewException e) {             out.println("Exception: " + e);         }     %>                         

Leave a Reply

Your email address will not be published. Required fields are marked *