mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
chore: remove legacy exception handler and adjust runtime class location
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
package work.slhaf.partner.framework.agent.common.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public abstract class PersistableObject implements Serializable {
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package work.slhaf.partner.framework.agent.config
|
||||
import com.alibaba.fastjson2.JSON
|
||||
import com.alibaba.fastjson2.JSONObject
|
||||
import org.slf4j.LoggerFactory
|
||||
import work.slhaf.partner.framework.agent.common.support.DirectoryWatchSupport
|
||||
import work.slhaf.partner.framework.agent.exception.AgentLaunchFailedException
|
||||
import work.slhaf.partner.framework.agent.support.DirectoryWatchSupport
|
||||
import java.io.IOException
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package work.slhaf.partner.framework.agent.exception;
|
||||
|
||||
public interface AgentExceptionCallback {
|
||||
void onRuntimeException(AgentRuntimeException e);
|
||||
|
||||
void onFailedException(AgentLaunchFailedException e);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package work.slhaf.partner.framework.agent.exception;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
public static GlobalExceptionHandler INSTANCE = new GlobalExceptionHandler();
|
||||
|
||||
private AgentExceptionCallback exceptionCallback = new LogAgentExceptionCallback();
|
||||
|
||||
public static void setExceptionCallback(AgentExceptionCallback callback) {
|
||||
INSTANCE.exceptionCallback = callback;
|
||||
}
|
||||
|
||||
public boolean handle(Throwable e) {
|
||||
boolean exit;
|
||||
Throwable cause = e.getCause();
|
||||
switch (cause) {
|
||||
case AgentRunningFailedException arfe -> {
|
||||
exit = true;
|
||||
exceptionCallback.onRuntimeException((AgentRuntimeException) cause);
|
||||
}
|
||||
case AgentRuntimeException are -> {
|
||||
exit = false;
|
||||
exceptionCallback.onRuntimeException((AgentRuntimeException) cause);
|
||||
}
|
||||
case AgentLaunchFailedException alfe -> {
|
||||
exit = true;
|
||||
exceptionCallback.onFailedException((AgentLaunchFailedException) cause);
|
||||
}
|
||||
default -> {
|
||||
exit = true;
|
||||
log.error("意外异常: ", cause);
|
||||
}
|
||||
}
|
||||
return exit;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package work.slhaf.partner.framework.agent.exception;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class LogAgentExceptionCallback implements AgentExceptionCallback {
|
||||
|
||||
@Override
|
||||
public void onRuntimeException(AgentRuntimeException e) {
|
||||
log.error("Agent 运行异常: ", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailedException(AgentLaunchFailedException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package work.slhaf.partner.framework.agent.factory.exception;
|
||||
|
||||
public class ExternalModulePathNotExistException extends AgentRegisterFactoryFailedException {
|
||||
public ExternalModulePathNotExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ExternalModulePathNotExistException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,11 @@ import com.alibaba.fastjson2.annotation.JSONCreator
|
||||
import com.alibaba.fastjson2.annotation.JSONField
|
||||
import com.fasterxml.jackson.annotation.JsonCreator
|
||||
import com.fasterxml.jackson.annotation.JsonValue
|
||||
import work.slhaf.partner.framework.agent.common.entity.PersistableObject
|
||||
import java.io.Serial
|
||||
|
||||
data class Message(
|
||||
val role: Character,
|
||||
val content: String
|
||||
) : PersistableObject() {
|
||||
) {
|
||||
|
||||
fun roleValue(): String = role.value
|
||||
|
||||
@@ -34,8 +32,4 @@ data class Message(
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Serial
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package work.slhaf.partner.framework.agent.common.support;
|
||||
package work.slhaf.partner.framework.agent.support;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -3,7 +3,7 @@ package work.slhaf.partner.framework.common.support;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import work.slhaf.partner.framework.agent.common.support.DirectoryWatchSupport;
|
||||
import work.slhaf.partner.framework.agent.support.DirectoryWatchSupport;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
Reference in New Issue
Block a user