1 Reply Latest reply on Feb 20, 2013 10:42 PM by Ayush Ganeriwal-Oracle

    JAVA BEANSHELL EXCEPTION HANDLING

    grimrand
      Hi

      still new to ODI

      I have created a java beanshell script in ODI which calls a simple java class, cars, then sets the no of seats to a value designed to raise an exception. Exception raised but procedure works OK,

      How can I register the fact that it has failed through exception handling? (It is possible that my java exception handling isn't quite right)

      The no of seats has no effect on the success/failure of the ODI procedure, but the log shows that the exception is caught !
      any assistance gratefully received.


      Regards

      Terry




      cars class: (added to agent start)
      ====================


      public class cars {
      private int seats;

      public void setSeats (int seats) throws tooManySeatsException {
      if (seats) < 100) {
      this .seats = seats;
      } else {
      throw new tooManySeatsException("Too many seats");
      }

      public int getSeats () {
      return this.seats;
      }


      class tooManySeatsException extends Exception {

      public tooManySeatsException (String msg){
      super();
      }
      }
      }






      Java beanshell procedure in ODI
      ====================

      import cars;

      public class carsTest {

      public carsTest(){
      }

      public void init(){
      cars c = new cars();

      c.setSeats(20);
      //c.setseats(200);

      }

      }


      try {
      carsTest ct = new carsTest();
      ct.init();
      } catch (Exception e) {

      throw Error (e);
      }