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

This commit is contained in:
Looly 2023-08-08 19:03:56 +08:00
parent d5ac761f08
commit cd53378ae3
35 changed files with 155 additions and 92 deletions

View File

@ -18,6 +18,7 @@ import org.dromara.hutool.core.collection.set.SetUtil;
import org.dromara.hutool.core.collection.set.UniqueKeySet;
import org.dromara.hutool.core.comparator.CompareUtil;
import org.dromara.hutool.core.convert.Convert;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.map.MapUtil;
@ -1156,7 +1157,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
return (Object[]) obj;
}
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
throw new HutoolException(StrUtil.format("[{}] is not Array!", obj.getClass()));

View File

@ -13,6 +13,7 @@
package org.dromara.hutool.core.classloader;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.net.url.URLUtil;
import org.dromara.hutool.core.reflect.method.MethodUtil;
@ -73,7 +74,7 @@ public class JarClassLoader extends URLClassLoader {
}
}
} catch (final IOException e) {
throw new HutoolException(e);
throw new IORuntimeException(e);
}
}

View File

@ -26,6 +26,7 @@ import org.dromara.hutool.core.comparator.PinyinComparator;
import org.dromara.hutool.core.comparator.PropertyComparator;
import org.dromara.hutool.core.convert.CompositeConverter;
import org.dromara.hutool.core.convert.Convert;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.func.SerBiConsumer;
import org.dromara.hutool.core.func.SerConsumer3;
@ -764,7 +765,7 @@ public class CollUtil {
if (null != superclass && collectionType != superclass) {
return create(superclass);
}
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
return list;

View File

@ -16,6 +16,7 @@ import org.dromara.hutool.core.convert.AbstractConverter;
import org.dromara.hutool.core.convert.ConvertException;
import org.dromara.hutool.core.date.DateTime;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.date.SqlDateUtil;
import org.dromara.hutool.core.text.StrUtil;
import java.time.temporal.TemporalAccessor;
@ -113,13 +114,13 @@ public class DateConverter extends AbstractConverter {
return date;
}
if (java.sql.Date.class == targetClass) {
return date.toSqlDate();
return SqlDateUtil.date(date);
}
if (java.sql.Time.class == targetClass) {
return new java.sql.Time(date.getTime());
return SqlDateUtil.time(date);
}
if (java.sql.Timestamp.class == targetClass) {
return date.toTimestamp();
return SqlDateUtil.timestamp(date);
}
throw new UnsupportedOperationException(StrUtil.format("Unsupported target Date type: {}", targetClass.getName()));

View File

@ -22,7 +22,6 @@ import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.core.util.SystemUtil;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
@ -724,24 +723,6 @@ public class DateTime extends Date {
return new Date(this.getTime());
}
/**
* 转为{@link Timestamp}
*
* @return {@link Timestamp}
*/
public Timestamp toTimestamp() {
return new Timestamp(this.getTime());
}
/**
* 转为 {@link java.sql.Date}
*
* @return {@link java.sql.Date}
*/
public java.sql.Date toSqlDate() {
return new java.sql.Date(getTime());
}
/**
* 转换为 {@link LocalDateTime}
*

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2023 looly(loolly@aliyun.com)
* Hutool is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.dromara.hutool.core.date;
import org.dromara.hutool.core.lang.Assert;
import java.sql.Timestamp;
import java.util.Date;
/**
* {@code java.sql.*}日期时间相关封装<br>
* 考虑到JDK9+模块化后java.sql并非默认引入模块因此将相关内容单独封装为工具避免类找不到问题
*
* @author looly
* @since 6.0.0
*/
public class SqlDateUtil {
/**
* 转为{@link Timestamp}
*
* @param date 日期时间非空
* @return {@link Timestamp}
*/
public static Timestamp timestamp(final Date date) {
Assert.notNull(date);
return new Timestamp(date.getTime());
}
/**
* /**
* 转为{@link java.sql.Date}
*
* @param date 日期时间非空
* @return {@link java.sql.Date}
*/
public static java.sql.Date date(final Date date) {
Assert.notNull(date);
return new java.sql.Date(date.getTime());
}
/**
* /**
* 转为{@link java.sql.Time}
*
* @param date 日期时间非空
* @return {@link java.sql.Time}
*/
public static java.sql.Time time(final Date date) {
Assert.notNull(date);
return new java.sql.Time(date.getTime());
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.exception;
import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.core.io.stream.FastByteArrayOutputStream;
import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.reflect.ConstructorUtil;
@ -19,6 +20,7 @@ import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.text.CharUtil;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.UndeclaredThrowableException;
@ -66,10 +68,13 @@ public class ExceptionUtil {
* @return 运行时异常
*/
public static RuntimeException wrapRuntime(final Throwable throwable) {
if(throwable instanceof IOException){
return new IORuntimeException(throwable);
}
if (throwable instanceof RuntimeException) {
return (RuntimeException) throwable;
}
return new RuntimeException(throwable);
return new HutoolException(throwable);
}
/**

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -62,7 +63,7 @@ public interface SerBiConsumer<T, U> extends BiConsumer<T, U>, Serializable {
try {
accepting(t, u);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -52,7 +53,7 @@ public interface SerBiFunction<T, U, R> extends BiFunction<T, U, R>, Serializabl
try {
return this.applying(t, u);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -54,7 +55,7 @@ public interface SerBiPredicate<T, U> extends BiPredicate<T, U>, Serializable {
try {
return testing(t, u);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -51,7 +52,7 @@ public interface SerBinaryOperator<T> extends BinaryOperator<T>, Serializable {
try {
return this.applying(t, u);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -47,7 +48,7 @@ public interface SerConsumer<T> extends Consumer<T>, Serializable {
try {
accepting(t);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -50,7 +51,7 @@ public interface SerConsumer3<P1, P2, P3> extends Serializable {
try {
accepting(p1, p2, p3);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -48,7 +49,7 @@ public interface SerFunction<T, R> extends Function<T, R>, Serializable {
try {
return applying(t);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -51,7 +52,7 @@ public interface SerPredicate<T> extends Predicate<T>, Serializable {
try {
return testing(t);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -13,6 +13,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -57,7 +58,7 @@ public interface SerRunnable extends Runnable, Serializable {
try {
running();
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -46,7 +47,7 @@ public interface SerSupplier<R> extends Supplier<R>, Serializable {
try {
return getting();
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.func;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import java.io.Serializable;
@ -48,7 +49,7 @@ public interface SerUnaryOperator<T> extends UnaryOperator<T>, Serializable {
try {
return applying(t);
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -119,7 +119,7 @@ public class LineReader extends ReaderWrapper implements Iterable<String> {
try {
return readLine();
} catch (final IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
}
};

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.io.file;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.func.SerConsumer;
import org.dromara.hutool.core.func.SerFunction;
@ -31,34 +32,37 @@ import java.util.function.Predicate;
* 文件读取器
*
* @author Looly
*
*/
public class FileReader extends FileWrapper {
private static final long serialVersionUID = 1L;
/**
* 创建 FileReader
* @param file 文件
*
* @param file 文件
* @param charset 编码使用 {@link CharsetUtil}
* @return FileReader
*/
public static FileReader of(final File file, final Charset charset){
public static FileReader of(final File file, final Charset charset) {
return new FileReader(file, charset);
}
/**
* 创建 FileReader, 编码{@link FileWrapper#DEFAULT_CHARSET}
*
* @param file 文件
* @return FileReader
*/
public static FileReader of(final File file){
public static FileReader of(final File file) {
return new FileReader(file, DEFAULT_CHARSET);
}
// ------------------------------------------------------- Constructor start
/**
* 构造
* @param file 文件
*
* @param file 文件
* @param charset 编码使用 {@link CharsetUtil}
*/
public FileReader(final File file, final Charset charset) {
@ -88,7 +92,7 @@ public class FileReader extends FileWrapper {
* @return 内容
* @throws IORuntimeException IO异常
*/
public String readString() throws IORuntimeException{
public String readString() throws IORuntimeException {
// JDK11+不再推荐使用这种方式推荐使用Files.readString
return new String(readBytes(), this.charset);
}
@ -96,7 +100,7 @@ public class FileReader extends FileWrapper {
/**
* 从文件中读取每一行数据
*
* @param <T> 集合类型
* @param <T> 集合类型
* @param collection 集合
* @return 文件中的每行内容的集合
* @throws IORuntimeException IO异常
@ -108,15 +112,15 @@ public class FileReader extends FileWrapper {
/**
* 从文件中读取每一行数据
*
* @param <T> 集合类型
* @param <T> 集合类型
* @param collection 集合
* @param predicate 断言断言为真的加入到提供的集合中
* @param predicate 断言断言为真的加入到提供的集合中
* @return 文件中的每行内容的集合
* @throws IORuntimeException IO异常
*/
public <T extends Collection<String>> T readLines(final T collection, final Predicate<String> predicate) throws IORuntimeException {
readLines((SerConsumer<String>) s -> {
if(null == predicate || predicate.test(s)){
if (null == predicate || predicate.test(s)) {
collection.add(s);
}
});
@ -130,7 +134,7 @@ public class FileReader extends FileWrapper {
* @throws IORuntimeException IO异常
* @since 3.0.9
*/
public void readLines(final SerConsumer<String> lineHandler) throws IORuntimeException{
public void readLines(final SerConsumer<String> lineHandler) throws IORuntimeException {
BufferedReader reader = null;
try {
reader = FileUtil.getReader(file, charset);
@ -153,7 +157,7 @@ public class FileReader extends FileWrapper {
/**
* 按照给定的readerHandler读取文件中的数据
*
* @param <T> 读取的结果对象类型
* @param <T> 读取的结果对象类型
* @param readerHandler Reader处理类
* @return 从文件中read出的数据
* @throws IORuntimeException IO异常
@ -165,13 +169,7 @@ public class FileReader extends FileWrapper {
reader = FileUtil.getReader(this.file, charset);
result = readerHandler.applying(reader);
} catch (final Exception e) {
if(e instanceof IOException){
throw new IORuntimeException(e);
} else if(e instanceof RuntimeException){
throw (RuntimeException)e;
} else{
throw new HutoolException(e);
}
throw ExceptionUtil.wrapRuntime(e);
} finally {
IoUtil.closeQuietly(reader);
}
@ -216,19 +214,19 @@ public class FileReader extends FileWrapper {
/**
* 将文件写入流中
*
* @param out
* @param out
* @param isCloseOut 是否关闭输出流
* @return 写出的流byte数
* @throws IORuntimeException IO异常
* @since 5.5.2
*/
public long writeToStream(final OutputStream out, final boolean isCloseOut) throws IORuntimeException {
try (final FileInputStream in = new FileInputStream(this.file)){
try (final FileInputStream in = new FileInputStream(this.file)) {
return IoUtil.copy(in, out);
}catch (final IOException e) {
} catch (final IOException e) {
throw new IORuntimeException(e);
} finally{
if(isCloseOut){
} finally {
if (isCloseOut) {
IoUtil.closeQuietly(out);
}
}

View File

@ -271,7 +271,7 @@ public class FileTypeUtil {
try {
return IoUtil.readHex(in, Math.min(8192, in.available()), false);
} catch (final IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
}

View File

@ -76,7 +76,7 @@ public class PathDeleter {
try (final Stream<Path> list = Files.list(this.path)){
list.forEach(PathUtil::del);
} catch (final IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
}
@ -89,7 +89,7 @@ public class PathDeleter {
try {
Files.walkFileTree(path, DelVisitor.INSTANCE);
} catch (final IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
}

View File

@ -17,6 +17,7 @@ import org.dromara.hutool.core.collection.iter.EnumerationIter;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.text.split.SplitUtil;
import org.dromara.hutool.core.text.CharUtil;
@ -367,9 +368,7 @@ public class NetUtil {
throw new HutoolException(e);
}
if (networkInterfaces == null) {
throw new HutoolException("Get network interface error!");
}
Assert.notNull(networkInterfaces, ()-> new HutoolException("Get network interface error!"));
final LinkedHashSet<InetAddress> ipSet = new LinkedHashSet<>();

View File

@ -15,6 +15,8 @@ package org.dromara.hutool.core.reflect;
import org.dromara.hutool.core.classloader.ClassLoaderUtil;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.iter.EnumerationIter;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.core.io.file.FileNameUtil;
import org.dromara.hutool.core.io.resource.ResourceUtil;
@ -408,7 +410,7 @@ public class ClassScanner implements Serializable {
classesOfLoadError.add(className);
} catch (final Throwable e){
if(!this.ignoreLoadError) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}else{
classesOfLoadError.add(className);
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.reflect.method;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.reflect.lookup.LookupUtil;
@ -51,7 +52,7 @@ public class MethodHandleUtil {
try {
return (T) methodHandle.invokeWithArguments(args);
} catch (final Throwable e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
@ -114,10 +115,7 @@ public class MethodHandleUtil {
}
return (T) handle.invokeWithArguments(args);
} catch (final Throwable e) {
if(e instanceof RuntimeException){
throw (RuntimeException)e;
}
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@ -18,6 +18,7 @@ import org.dromara.hutool.core.classloader.ClassLoaderUtil;
import org.dromara.hutool.core.collection.set.SetUtil;
import org.dromara.hutool.core.collection.set.UniqueKeySet;
import org.dromara.hutool.core.convert.Convert;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.lang.Singleton;
@ -753,7 +754,7 @@ public class MethodUtil {
return invoke(isSingleton ? Singleton.get(clazz) : ConstructorUtil.newInstance(clazz), method, args);
}
} catch (final Exception e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.core.thread;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.stream.StreamUtil;
@ -211,7 +212,7 @@ public class AsyncUtil {
if (eHandler != null) {
return eHandler.apply(ex);
} else {
throw new RuntimeException(ex);
throw ExceptionUtil.wrapRuntime(ex);
}
}
})

View File

@ -17,6 +17,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.reflect.ConstructorUtil;
import org.dromara.hutool.core.reflect.lookup.LookupUtil;
import org.junit.jupiter.api.Assertions;
@ -322,7 +323,7 @@ public class LambdaFactoryTest {
try {
return get0();
} catch (final Throwable e) {
throw new RuntimeException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
}

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.http.client.engine.jdk;
import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.net.url.UrlBuilder;
import org.dromara.hutool.core.text.StrUtil;
@ -79,7 +80,7 @@ public class JdkClientEngine implements ClientEngine {
} catch (final IOException e) {
// 出错后关闭连接
IoUtil.closeQuietly(this);
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
return sendRedirectIfPossible(message, isAsync);

View File

@ -557,7 +557,7 @@ public class JakartaServletUtil {
writer.write(text);
writer.flush();
} catch (final IOException e) {
throw new HutoolException(e);
throw new IORuntimeException(e);
} finally {
IoUtil.closeQuietly(writer);
}

View File

@ -568,7 +568,7 @@ public class ServletUtil {
writer.write(text);
writer.flush();
} catch (final IOException e) {
throw new HutoolException(e);
throw new IORuntimeException(e);
} finally {
IoUtil.closeQuietly(writer);
}

View File

@ -1,5 +1,6 @@
package org.dromara.hutool.poi.excel;
import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.poi.excel.cell.CellUtil;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
@ -42,7 +43,7 @@ public class IssueI6MBS5Test {
CellUtil.setComment(cell, "commonText", "ascend", null);
workbook.write(Files.newOutputStream(file.toPath()));
} catch (final IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
}
}

View File

@ -12,16 +12,11 @@
package org.dromara.hutool.swing.clipboard;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.exception.ExceptionUtil;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.datatransfer.*;
import java.io.IOException;
/**
@ -82,7 +77,7 @@ public class ClipboardUtil {
try {
return content.getTransferData(flavor);
} catch (final UnsupportedFlavorException | IOException e) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
}
return null;

View File

@ -12,6 +12,7 @@
package org.dromara.hutool.swing.img;
import org.dromara.hutool.core.exception.ExceptionUtil;
import org.dromara.hutool.core.exception.HutoolException;
import org.dromara.hutool.core.io.IORuntimeException;
@ -76,7 +77,7 @@ public class FontUtil {
try {
return Font.createFont(Font.TYPE1_FONT, fontFile);
} catch (final Exception e1) {
throw new HutoolException(e);
throw ExceptionUtil.wrapRuntime(e);
}
} catch (final IOException e) {
throw new IORuntimeException(e);
@ -98,7 +99,7 @@ public class FontUtil {
try {
return Font.createFont(Font.TYPE1_FONT, fontStream);
} catch (final Exception e1) {
throw new HutoolException(e1);
throw ExceptionUtil.wrapRuntime(e1);
}
} catch (final IOException e) {
throw new IORuntimeException(e);

View File

@ -47,7 +47,7 @@ public class ImgMetaUtil {
} catch (final ImageProcessingException e) {
throw new HutoolException(e);
} catch (final IOException e) {
throw new RuntimeException(e);
throw new IORuntimeException(e);
}
return getOrientation(metadata);
}