title: Javascript Custom Exception
body: <p>I have tried for a couple of days researching on how to create a custom exception in a try/catch.</p>
  
  <p>Here is what I am attempting to do:</p>
  
  <p>I have an included JS file in my html page. The JS file defines a custom object, as well as defining methods for the object.</p>
  
  <p>Next, in the html page I am doing the following:</p>
  
  <pre><code>try {
     MyObj = new CustomObj;     //from the included JS file.
     MyObj.CustomMethod();      //also from the included JS file.
  } catch(e) {
     alert("Error in either the create of the object, or the method. Error is " + e.description)
  }
  </code></pre>
  
  <p>I need to be able, within the code for the CustomMethod(), to set the Error Object's properties that are captured in the catch statement. For example:</p>
  
  <pre><code>  CustomMethod = function{
       try{
         document.getelementById("field1").value = "my value";
       } catch(err) {
         //Set the return error
         ReturnErr.description = "There was an error!";
       }
    };
  </code></pre>
  
  <p>Can this be done? From what I have tried, I have used the throw statement, but it does not effect the Error Object, thus the catch section is never triggered. In face, the custom message is only shown in the Console.</p>
  
  <p>Thanks ahead of time.</p>