Commit cfb1cba2 authored by yanzg's avatar yanzg

将源码打包进jar包

parent 0a5e45a6
...@@ -2,6 +2,7 @@ package com.yanzuoguang.util.exception; ...@@ -2,6 +2,7 @@ package com.yanzuoguang.util.exception;
import com.yanzuoguang.util.contants.ResultConstants; import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.ResponseResult; import com.yanzuoguang.util.vo.ResponseResult;
/** /**
...@@ -21,14 +22,14 @@ public class ExceptionHelper { ...@@ -21,14 +22,14 @@ public class ExceptionHelper {
} }
/** /**
* 不出异常,记录日常日志 * 不出异常,记录日常日志
* *
* @param cls * @param cls 错误类型
* @param ex * @param ex 错误
* @param from * @param from 错误资源
*/ */
public static void handleException(Class<?> cls, Throwable ex, Object 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 { ...@@ -37,12 +38,12 @@ public class ExceptionHelper {
* @param local * @param local
* @param start * @param start
* @param end * @param end
* @param allsize * @param allSize
* @param str * @param str
* @throws Exception * @throws Exception
*/ */
public static void subStringException(String local, int start, int end, int allsize, String 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; String exception = local + "/n" + "开始:" + start + " 结束:" + end + "总长:" + allSize + "/n" + str;
throw new Exception(exception); throw new Exception(exception);
} }
...@@ -53,7 +54,7 @@ public class ExceptionHelper { ...@@ -53,7 +54,7 @@ public class ExceptionHelper {
* @param e 异常信息 * @param e 异常信息
* @return 返回的数据 * @return 返回的数据
*/ */
public static ResponseResult getError(Exception e) { public static ResponseResult<?> getError(Exception e) {
return getError(e, false); return getError(e, false);
} }
...@@ -63,7 +64,7 @@ public class ExceptionHelper { ...@@ -63,7 +64,7 @@ public class ExceptionHelper {
* @param e 异常信息 * @param e 异常信息
* @return 返回的数据 * @return 返回的数据
*/ */
public static ResponseResult getError(Exception e, boolean isFull) { public static ResponseResult<?> getError(Exception e, boolean isFull) {
if (e instanceof CodeTargetException) { if (e instanceof CodeTargetException) {
CodeTargetException code = (CodeTargetException) e; CodeTargetException code = (CodeTargetException) e;
return getError(code.getCode(), code.getMessage(), code.getTarget(), true); return getError(code.getCode(), code.getMessage(), code.getTarget(), true);
...@@ -79,7 +80,7 @@ public class ExceptionHelper { ...@@ -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) { if (isFull) {
return ResponseResult.error(code, msg, target); return ResponseResult.error(code, msg, target);
} else { } 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