@Test public void testFormatException(){ WebApiException e = new WebApiException(ExcepFactor.E_PARAM_INVALID_ERROR, "param error"); String result = WebExceptionFormat.formatException(e, "/user/test", "json"); ApiLogger.debug("testFormatException result:" + result); }
public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, path, factor.getErrorCode(), e.getMessage()); } else if ("str".equals(type)) { result = String.format(strMsg, path, factor.getErrorCode(), e.getMessage(), factor.getErrorMsgCn()); } else { result = String.format(jsonMsg, path, factor.getErrorCode(), e.getMessage()); } return result; }
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, path, factor.getErrorCode(), e.getMessage()); } else if ("str".equals(type)) { result = String.format(strMsg, path, factor.getErrorCode(), e.getMessage(), factor.getErrorMsgCn()); } else { result = String.format(jsonMsg, path, factor.getErrorCode(), e.getMessage()); } return result; } }
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, path, factor.getErrorCode(), e.getMessage()); } else if ("str".equals(type)) { result = String.format(strMsg, path, factor.getErrorCode(), e.getMessage(), factor.getErrorMsgCn()); } else { result = String.format(jsonMsg, path, factor.getErrorCode(), e.getMessage()); } return result; }  }
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, path, factor.getErrorCode(), e.getMessage()); } else if ("str".equals(type)) { result = String.format(strMsg, path, factor.getErrorCode(), e.getMessage(), factor.getErrorMsgCn()); } else { result = String.format(jsonMsg, path, factor.getErrorCode(), e.getMessage()); } return result; }  static String formatException(WebApiException e, String path, String type); }
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, path, factor.getErrorCode(), e.getMessage()); } else if ("str".equals(type)) { result = String.format(strMsg, path, factor.getErrorCode(), e.getMessage(), factor.getErrorMsgCn()); } else { result = String.format(jsonMsg, path, factor.getErrorCode(), e.getMessage()); } return result; }  static String formatException(WebApiException e, String path, String type);  }