public void test_error() throws Exception { ErrorSizeBean obj = new ErrorSizeBean(); Exception error = null; try { JSONPath.eval(obj, "$.size()"); } catch (JSONPathException ex) { error = ex; } Assert.assertNotNull(error); Assert.assertNotNull(error.getCause()); }
public void test_path_empty() throws Exception { Throwable error = null; try { JSONPath.compile(""); } catch (JSONPathException ex) { error = ex; } Assert.assertNotNull(error); }
public void test_path_null() throws Exception { Throwable error = null; try { JSONPath.compile(null); } catch (JSONPathException ex) { error = ex; } Assert.assertNotNull(error); }
public void test_path_null_1() throws Exception { Throwable error = null; try { new JSONPath(null); } catch (JSONPathException ex) { error = ex; } Assert.assertNotNull(error); }
/** * 解析异常 * * @param e * @return */ public static ApiException analysisExcetpion(Throwable e) { ApiException apiException = new ApiException(e); if (e instanceof HttpException) { /*网络异常*/ apiException.setCode(CodeException.HTTP_ERROR); apiException.setDisplayMessage(HttpException_MSG); } else if (e instanceof HttpTimeException) { /*自定义运行时异常*/ HttpTimeException exception = (HttpTimeException) e; apiException.setCode(CodeException.RUNTIME_ERROR); apiException.setDisplayMessage(exception.getMessage()); } else if (e instanceof ConnectException||e instanceof SocketTimeoutException) { /*链接异常*/ apiException.setCode(CodeException.HTTP_ERROR); apiException.setDisplayMessage(ConnectException_MSG); } else if (e instanceof JSONPathException || e instanceof JSONException || e instanceof ParseException) { /*fastjson解析异常*/ apiException.setCode(CodeException.JSON_ERROR); apiException.setDisplayMessage(JSONException_MSG); }else if (e instanceof UnknownHostException){ /*无法解析该域名异常*/ apiException.setCode(CodeException.UNKOWNHOST_ERROR); apiException.setDisplayMessage(UnknownHostException_MSG); } else { /*未知异常*/ apiException.setCode(CodeException.UNKNOWN_ERROR); apiException.setDisplayMessage(e.getMessage()); } return apiException; }