def x = new String[3] x[0] = "A" x[1] = "B" x[2] = "C" log.info"XXXXXX 1" try{ x[3] = "D" // def z=9/0 }catch(Exception e){ log.info "Some error "+e.getMessage() // Use e.getMessage() to print exception information // e.printStackTrace() // This one is used to print the process of invoking functions } log.info"XXXXXX 2"
Result:
Tue Oct 06 21:47:38 CST 2015:INFO:XXXXXX 1 Tue Oct 06 21:47:38 CST 2015:INFO:Some error 3 Tue Oct 06 21:47:38 CST 2015:INFO:XXXXXX 2