示例#1
0
 public static <T> Response<T> fault(T data, ErrorCode code) {
   if (code != null) {
     return new Response<T>(data, "FAULT", code.toString(), code.getErrorMessage());
   } else {
     return new Response<T>(data, "FAULT", null, null);
   }
 }
示例#2
0
 public static <T> Response<T> fault(Exception e) {
   ErrorCode code = null;
   if (e instanceof VMwareException) {
     code = ((VMwareException) e).getErrorCode();
   }
   if (code == null) {
     code = ErrorCode.NONE;
   }
   StringBuffer message = new StringBuffer(e.toString());
   if (e.getCause() != null) {
     message.append("\n  Cause by: " + e.getCause().toString());
     for (StackTraceElement ste : e.getCause().getStackTrace()) {
       message.append("\n\t" + ste);
     }
   }
   return new Response<T>(null, "FAULT", code.toString(), message.toString());
 }