title: Is it good programming to have a return type of Exception?
body: <p>I ran into an odd situation during a use case on a project: ESQL is calling a java method, sending it a String input parameter which the method will unmarshal, apply some logic, and then store useful info from the unmarshalled object. So, the method must either throw a JAXBException, or use a try catch in order to handle the possible exceptions.</p>
  
  <p>The problem with this is, that ESQL cannot invoke a java method which includes a throws in the signature. BUT, we want any errors to fall through back to the previously calling MBNode so it can be handled appropriately there, so then trycatch is out of the picture.</p>
  
  <p>It struck me that hey, is it not possible to return a type of Exception when we encounter an issue, and null if not? So I wrote a simple method doing so, and though I didn't get any warnings or errors, it seemed just wrong to me in the sense of good programming.</p>
  
  <p>For example:</p>
  
  <pre><code>public Exception doStuffAndCheckForErorrs(String inString)
  {
      if(inString.equals(null))
      {
         return new Exception("Your string is null");
      }
      else
      return null;
  }
  </code></pre>
  
  <p>But I just get a terrible feeling about doing anything this way.</p>
  
  <p>I'm open to any thoughts or different solutions to this, especially if there's a way around the ESQL signature issue.</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>Adding reference as to why the ESQL procedure cannot call a java method with a throws clause in the signature.</p>
  
  <p>Excerpt from <a href="https://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fac06009_.htm" rel="nofollow">This link</a> under the CREATE PROCEDURE statement section:</p>
  
  <p>"Any Java method that you want to invoke must have the following basic signature:
          public static   (&lt; 0 - N parameters>)
          where  must be in the list of Java IN data types in the table in ESQL to Java data type mapping (excluding the REFERENCE type, which is not permitted as a return value), or the Java void data type. The parameter data types must also be in the ESQL to Java data type mapping table. In addition, <strong>the Java method is not allowed to have an exception throws clause in its signature</strong>."</p>