feat():字符集异常

master
WeiRan 2024-08-09 10:57:51 +08:00
parent 5c8b06f6cb
commit 0ba727773a
1 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.muyu.common.core.text; package com.muyu.common.core.text;
import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.StringUtils;
import lombok.extern.log4j.Log4j2;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
@ -15,6 +16,7 @@ import java.util.Set;
* *
* @author muyu * @author muyu
*/ */
@Log4j2
public class Convert { public class Convert {
/** /**
* <br> * <br>
@ -687,9 +689,18 @@ public class Convert {
* @return * @return
*/ */
public static String str (Object obj, String charsetName) { public static String str (Object obj, String charsetName) {
return str(obj, Charset.forName(charsetName)); try{
return str(obj, Charset.forName(charsetName));
}catch (Exception exception){
log.error("字符转换异常:[{}->{}]->{}",obj,charsetName,exception.getMessage(),exception);
throw new RuntimeException(exception);
}
} }
/** /**
* <br> * <br>
* 1ByteByteBuffer 2Arrays.toString * 1ByteByteBuffer 2Arrays.toString