41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
|
|
package com.arthenica.smartexception.java;
|
||
|
|
|
||
|
|
import java.io.PrintWriter;
|
||
|
|
import java.io.StringWriter;
|
||
|
|
import java.util.Collections;
|
||
|
|
import java.util.HashSet;
|
||
|
|
import java.util.Set;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* smartexception-java 的最小 stub
|
||
|
|
* ffmpeg-kit 6.0.2 内部 swordfish 库依赖此类的 getStackTraceString / registerRootPackage
|
||
|
|
* 我们不需要完整功能,只需保证类存在且方法签名匹配
|
||
|
|
*/
|
||
|
|
public class Exceptions {
|
||
|
|
|
||
|
|
private static final Set<String> rootPackages = Collections.synchronizedSet(new HashSet<String>());
|
||
|
|
|
||
|
|
public static void registerRootPackage(String rootPackage) {
|
||
|
|
if (rootPackage != null) {
|
||
|
|
rootPackages.add(rootPackage);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static String[] getRegisteredRootPackages() {
|
||
|
|
return rootPackages.toArray(new String[0]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void unregisterRootPackage(String rootPackage) {
|
||
|
|
if (rootPackage != null) {
|
||
|
|
rootPackages.remove(rootPackage);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static String getStackTraceString(Throwable t) {
|
||
|
|
if (t == null) return "";
|
||
|
|
StringWriter sw = new StringWriter();
|
||
|
|
t.printStackTrace(new PrintWriter(sw));
|
||
|
|
return sw.toString();
|
||
|
|
}
|
||
|
|
}
|