title: JMeter Beanshell Error handling using try/catch
body: <p>I'm trying to use beanshell try catch scripting but I struggle with it. so few questions:</p>
  
  <p>Why when I try to run the following code I receive error, <strong>and not the catch statement "Error in beanshell?</strong></p>
  
  <pre><code>String str = "a";
  try {
      log.info(str)
  }
  
  catch (Exception ex) {
      log.error("Error in beanshell", ex);
      throw ex;
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>2016/12/14 10:26:33 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   In file: inline evaluation of: ``String str = "a"; try {    log.info(str) }  catch (Exception ex) {     log.error("Err . . . '' Encountered "}" at line 4, column 1.
  
  2016/12/14 10:26:33 WARN  - jmeter.protocol.java.sampler.BeanShellSampler: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``String str = "a"; try {    log.info(str) }  catch (Exception ex) {     log.error("Err . . . '' Encountered "}" at line 4, column 1.
  </code></pre>
  
  <p>Secondly, When I run this code:</p>
  
  <pre><code>try {
      String str = "a";
      log.info(str)
  }
  
  catch (Exception ex) {
      log.error("Error in beanshell", ex);
      throw ex;
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>2016/12/14 10:27:25 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   In file: inline evaluation of: ``try {  String str = "a";   log.info(str) }  catch (Exception ex) {     log.error("Er . . . '' Encountered "}" at line 4, column 1.
  
  2016/12/14 10:27:25 WARN  - jmeter.protocol.java.sampler.BeanShellSampler: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``try {  String str = "a";   log.info(str) }  catch (Exception ex) {     log.error("Er . . . '' Encountered "}" at line 4, column 1.
  </code></pre>
  
  <p>Same, I don't understand why the Catch hasn't come in play.
  Also - what are is the difference between Catch Exception/Throwable/EvalError, etc?
  Thanks</p>