title: Validate if the input in the setter method is double or String
body: <p>The value in the setter comes from a JTextFeild. I have try different method but it isn't working. I want to print out my custom error message. It isn't working for double, the String variable print the error message in the stacktrace.</p>
  
  <p>This is the String method. </p>
  
  <pre><code>public void setInventoryname(String inventoryname) throws Exception {
          if(inventoryname.isEmpty()){
              throw new Exception ("Medicine name cannot be empty");
          }
          else{
          this.inventoryname = inventoryname;
      }
      }
  </code></pre>
  
  <p>result of the string method.</p>
  
  <pre><code> java.lang.Exception: Medicine name cannot be empty
  </code></pre>
  
  <p>This is the double method</p>
  
  <pre><code>public void setInventorydesc(double inventorydesc) throws Exception {
        if(!Double.toString(inventorydesc).isEmpty()){
  
            throw new Exception("Set a number in Inventory qunatity");
  
        }
        else
        {
          this.inventoryqty = inventorydesc;
  
        } 
      }
  </code></pre>
  
  <p>The result of double</p>
  
  <pre><code>java.lang.NumberFormatException: For input string: "dfasdf"
  </code></pre>
  
  <p>I want to receive the same result as of string for double.</p>