本文整理匯總了Java中com.alibaba.fastjson.JSONPathException類的典型用法代碼示例。如果您正苦於以下問題:Java JSONPathException類的具體用法?Java JSONPathException怎麽用?Java JSONPathException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JSONPathException類屬於com.alibaba.fastjson包,在下文中一共展示了JSONPathException類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test_error
import com.alibaba.fastjson.JSONPathException; //導入依賴的package包/類
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());
}
示例2: test_path_empty
import com.alibaba.fastjson.JSONPathException; //導入依賴的package包/類
public void test_path_empty() throws Exception {
Throwable error = null;
try {
JSONPath.compile("");
} catch (JSONPathException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例3: test_path_null
import com.alibaba.fastjson.JSONPathException; //導入依賴的package包/類
public void test_path_null() throws Exception {
Throwable error = null;
try {
JSONPath.compile(null);
} catch (JSONPathException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例4: test_path_null_1
import com.alibaba.fastjson.JSONPathException; //導入依賴的package包/類
public void test_path_null_1() throws Exception {
Throwable error = null;
try {
new JSONPath(null);
} catch (JSONPathException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例5: analysisExcetpion
import com.alibaba.fastjson.JSONPathException; //導入依賴的package包/類
/**
* 解析異常
*
* @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;
}