Commit cfb1cba2 authored by yanzg's avatar yanzg

将源码打包进jar包

parent 0a5e45a6
......@@ -2,6 +2,7 @@ package com.yanzuoguang.util.exception;
import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.ResponseResult;
/**
......@@ -21,14 +22,14 @@ public class ExceptionHelper {
}
/**
* 不出异常,记录日常日志
* 不出异常,记录日常日志
*
* @param cls
* @param ex
* @param from
* @param cls 错误类型
* @param ex 错误
* @param from 错误资源
*/
public static void handleException(Class<?> cls, Throwable ex, Object from) {
ex.printStackTrace();
Log.error(cls, ex, StringHelper.EMPTY, from);
}
/**
......@@ -37,12 +38,12 @@ public class ExceptionHelper {
* @param local
* @param start
* @param end
* @param allsize
* @param allSize
* @param str
* @throws Exception
*/
public static void subStringException(String local, int start, int end, int allsize, String str) throws Exception {
String exception = local + "/n" + "开始:" + start + " 结束:" + end + "总长:" + allsize + "/n" + str;
public static void subStringException(String local, int start, int end, int allSize, String str) throws Exception {
String exception = local + "/n" + "开始:" + start + " 结束:" + end + "总长:" + allSize + "/n" + str;
throw new Exception(exception);
}
......@@ -53,7 +54,7 @@ public class ExceptionHelper {
* @param e 异常信息
* @return 返回的数据
*/
public static ResponseResult getError(Exception e) {
public static ResponseResult<?> getError(Exception e) {
return getError(e, false);
}
......@@ -63,7 +64,7 @@ public class ExceptionHelper {
* @param e 异常信息
* @return 返回的数据
*/
public static ResponseResult getError(Exception e, boolean isFull) {
public static ResponseResult<?> getError(Exception e, boolean isFull) {
if (e instanceof CodeTargetException) {
CodeTargetException code = (CodeTargetException) e;
return getError(code.getCode(), code.getMessage(), code.getTarget(), true);
......@@ -79,7 +80,7 @@ public class ExceptionHelper {
}
}
private static ResponseResult getError(String code, String msg, Object target, boolean isFull) {
private static ResponseResult<?> getError(String code, String msg, Object target, boolean isFull) {
if (isFull) {
return ResponseResult.error(code, msg, target);
} else {
......
package helper;
import com.yanzuoguang.util.exception.ExceptionHelper;
import org.junit.Test;
public class TestExceptionHelper {
@Test
public void testException() {
ExceptionHelper.handleException(TestExceptionHelper.class, new Exception("错误"), "消息");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment