修改异常包装策略:运行时异常不包装,只包装非运行时异常

This commit is contained in:
Looly
2023-08-08 19:03:49 +08:00
parent e66681936f
commit 170c083907
15 changed files with 37 additions and 15 deletions

View File

@@ -531,7 +531,7 @@ public class IoUtil extends NioUtil {
int i = in.available();
return readHex(in, Math.min(8192, in.available()), false);
} catch (IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
}

View File

@@ -2,6 +2,7 @@ package cn.hutool.core.lang;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.EnumerationIter;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.resource.ResourceUtil;
@@ -398,7 +399,7 @@ public class ClassScanner implements Serializable {
classesOfLoadError.add(className);
} catch (Throwable e) {
if (false == this.ignoreLoadError) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
} else {
classesOfLoadError.add(className);
}

View File

@@ -1,6 +1,7 @@
package cn.hutool.core.lang;
import cn.hutool.core.collection.TransIter;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.lang.func.Func0;
import cn.hutool.core.lang.mutable.Mutable;
import cn.hutool.core.lang.mutable.MutableObj;
@@ -110,7 +111,7 @@ public class SimpleCache<K, V> implements Iterable<Map.Entry<K, V>>, Serializabl
try {
v = supplier.call();
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
put(key, v);
}

View File

@@ -1,5 +1,7 @@
package cn.hutool.core.lang.func;
import cn.hutool.core.exceptions.ExceptionUtil;
import java.io.Serializable;
/**
@@ -37,7 +39,7 @@ public interface Func<P, R> extends Serializable {
try {
return call(parameters);
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@@ -1,5 +1,7 @@
package cn.hutool.core.lang.func;
import cn.hutool.core.exceptions.ExceptionUtil;
import java.io.Serializable;
/**
@@ -33,7 +35,7 @@ public interface Func0<R> extends Serializable {
try {
return call();
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@@ -1,5 +1,7 @@
package cn.hutool.core.lang.func;
import cn.hutool.core.exceptions.ExceptionUtil;
import java.io.Serializable;
/**
@@ -37,7 +39,7 @@ public interface Func1<P, R> extends Serializable {
try {
return call(parameter);
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@@ -1,5 +1,7 @@
package cn.hutool.core.lang.func;
import cn.hutool.core.exceptions.ExceptionUtil;
import java.io.Serializable;
/**
@@ -35,7 +37,7 @@ public interface VoidFunc<P> extends Serializable {
try {
call(parameters);
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@@ -1,5 +1,7 @@
package cn.hutool.core.lang.func;
import cn.hutool.core.exceptions.ExceptionUtil;
import java.io.Serializable;
/**
@@ -31,7 +33,7 @@ public interface VoidFunc0 extends Serializable {
try {
call();
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@@ -1,5 +1,7 @@
package cn.hutool.core.lang.func;
import cn.hutool.core.exceptions.ExceptionUtil;
import java.io.Serializable;
/**
@@ -33,7 +35,7 @@ public interface VoidFunc1<P> extends Serializable {
try {
call(parameter);
} catch (Exception e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}