| 12345678910111213141516171819202122232425 |
- package com.mokamrp.privates.config;
- import com.mokamrp.privates.utils.Cmd;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Component;
- import org.springframework.web.bind.annotation.ControllerAdvice;
- import org.springframework.web.bind.annotation.ExceptionHandler;
- @ControllerAdvice
- public class ApiPanic {
- private final String feishu = "https://open.feishu.cn/open-apis/bot/v2/hook/538d8993-e23a-4836-863c-05515b41160e";
- @Value("${spring.profiles.active}")
- private String env;
- @ExceptionHandler(value = Exception.class)
- public String exceptionHandler(Exception e) {
- if (env.equals("prod")) {
- //.正式环境捕获API异常 推送到飞书
- if (e.getMessage() != null){
- Cmd.sendFeishuMsg(feishu, "[moka-private]:api panic " + e);
- }
- }
- return e.getMessage();
- }
- }
|