@Override
 public JsonElement serialize(Throwable src, Type typeOfSrc, JsonSerializationContext context) {
   JsonObject jsonObject = new JsonObject();
   jsonObject.add("class", new JsonPrimitive(src.getClass().getName()));
   if (src.getMessage() != null) {
     jsonObject.add("message", new JsonPrimitive(src.getMessage()));
   }
   return jsonObject;
 }
示例#2
0
文件: Job.java 项目: chouclee/h2o
 /**
  * Signal exceptional cancellation of this job.
  *
  * @param ex exception causing the termination of job.
  */
 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);
 }
示例#3
0
文件: Job.java 项目: chouclee/h2o
 public void onException(Throwable ex) {
   UKV.remove(dest());
   Value v = DKV.get(progressKey());
   if (v != null) {
     ChunkProgress p = v.get();
     p = p.error(ex.getMessage());
     DKV.put(progressKey(), p);
   }
   cancel(ex);
 }