[OpenApi] "+ip+"服务器内部错误
This commit is contained in:
+14
-1
@@ -1,6 +1,8 @@
|
|||||||
package com.fangjia.open.exceptionhander;
|
package com.fangjia.open.exceptionhander;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
@@ -17,12 +19,23 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler {
|
|||||||
if (LOGGER.isErrorEnabled()) {
|
if (LOGGER.isErrorEnabled()) {
|
||||||
LOGGER.error("", e);
|
LOGGER.error("", e);
|
||||||
}
|
}
|
||||||
|
String ip = getServerIp();
|
||||||
String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c";
|
String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c";
|
||||||
DingDingMessageUtil.sendTextMessage(token, "[OpenApi]服务器内部错误,请及时关注!");
|
DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!");
|
||||||
ActionContext context = ActionContext.getContext();
|
ActionContext context = ActionContext.getContext();
|
||||||
context.getResponse().setStatus(500);
|
context.getResponse().setStatus(500);
|
||||||
context.getResponse().setCharacterEncoding("UTF-8");
|
context.getResponse().setCharacterEncoding("UTF-8");
|
||||||
context.getResponse().setContentType("application/json;charset=UTF-8");
|
context.getResponse().setContentType("application/json;charset=UTF-8");
|
||||||
context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务器内部错误\"}");
|
context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务器内部错误\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getServerIp() {
|
||||||
|
try {
|
||||||
|
InetAddress inetAddress = InetAddress.getLocalHost();
|
||||||
|
return inetAddress.getHostAddress();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
LOGGER.error("Unable to get server IP address", e);
|
||||||
|
return "Unknown IP";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user