Ver Fonte

新增自定义异常统一提示

hubin há 1 ano atrás
pai
commit
229fb21dff
1 ficheiros alterados com 31 adições e 0 exclusões
  1. 31 0
      src/main/java/com/aizuda/boot/config/BootException.java

+ 31 - 0
src/main/java/com/aizuda/boot/config/BootException.java

@@ -0,0 +1,31 @@
+/*
+ * 爱组搭,低代码组件化开发平台
+ * ------------------------------------------
+ * 受知识产权保护,请勿删除版权申明,开发平台不允许做非法网站,后果自负
+ */
+package com.aizuda.boot.config;
+
+import com.aizuda.core.api.ApiResult;
+import com.flowlong.bpm.engine.exception.FlowLongException;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+/**
+ * 自定义异常统一提示
+ */
+@RestControllerAdvice
+public class BootException {
+
+    /**
+     * 工作流引擎异常提示
+     */
+    @ExceptionHandler(FlowLongException.class)
+    @ResponseStatus(HttpStatus.OK)
+    @ResponseBody
+    public ApiResult<String> handleBindException(FlowLongException e) {
+        return ApiResult.failed(e.getMessage());
+    }
+}