code: public void cancel(Throwable ex){
      if(ex instanceof JobCancelledException || ex.getMessage() != null && ex.getMessage().contains("job was cancelled"))
        return;
      if(ex instanceof  IllegalArgumentException || ex.getCause() instanceof IllegalArgumentException) {
        cancel("Illegal argument: " + ex.getMessage());
        return;
      }
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      String stackTrace = sw.toString();
      cancel("Got exception '" + ex.getClass() + "', with msg '" + ex.getMessage() + "'\n" + stackTrace, JobState.FAILED);
      if(_fjtask != null && !_fjtask.isDone()) _fjtask.completeExceptionally(ex);
    }
docs: Signal exceptional cancellation of this job.
  @param ex exception causing the termination of job.