All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edi.rule.frame.spring.component.JSRuleExceptionHandler Maven / Gradle / Ivy

package edi.rule.frame.spring.component;

import edi.rule.core.JSRuleController;
import edi.rule.extend.interfaces.IJSRuleHttpResponse;
import edi.rule.util.ZSString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import edi.rule.model.JSResult;
import edi.rule.work.custom.JSRuleException;

@Order(Ordered.HIGHEST_PRECEDENCE)
@Slf4j
@ControllerAdvice
public final class JSRuleExceptionHandler {
    /**
     * 

用于全局捕获漏掉的JSRuleException异常,通常在未使用内置{@link JSRuleController#start()}方法时会产生遗漏 *

此外若外部项目使用同样的手法对该异常进行捕获,则该方法有可能被截断而无法正常执行 * */ @ExceptionHandler(value = JSRuleException.class) @ResponseBody public IJSRuleHttpResponse JSRuleExceptionProcess(JSRuleException e) { /*处理本地log日志*/ if (ZSString.isBlank(e.log)){ log.error(e.getMessage(),e); }else{ log.error(e.log,e.params); } /*调用端响应对象*/ if (e.response ==null){ return JSResult.fail().setLog(e.getMessage()); }else{ return e.response; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy