|
@@ -1,7 +1,5 @@
|
|
|
package cn.com.qmth.stmms.api.controller;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -19,14 +17,18 @@ public class BaseApiController extends BaseController {
|
|
|
protected static final Logger log = LoggerFactory.getLogger(BaseApiController.class);
|
|
|
|
|
|
@ExceptionHandler
|
|
|
- public void exception(HttpServletResponse response, Exception ex) throws IOException {
|
|
|
+ public void exception(HttpServletResponse response, Exception ex) {
|
|
|
log.error("api execute error", ex);
|
|
|
response.addHeader(AuthInfoUtils.ERROR_MESSAGE_HEADER_KEY, StringUtils.trimToEmpty(ex.getMessage()));
|
|
|
- if (ex instanceof ApiException) {
|
|
|
- ApiException e = (ApiException) ex;
|
|
|
- response.sendError(e.getCode());
|
|
|
- } else {
|
|
|
- response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
|
|
+ try {
|
|
|
+ if (ex instanceof ApiException) {
|
|
|
+ ApiException e = (ApiException) ex;
|
|
|
+ response.sendError(e.getCode());
|
|
|
+ } else {
|
|
|
+ response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("api response senderror", e);
|
|
|
}
|
|
|
}
|
|
|
}
|