feat(configuration): 输出http异常
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.lanyuanxiaoyao.service.configuration.controller;
|
package com.lanyuanxiaoyao.service.configuration.controller;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
@@ -14,10 +16,13 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
|||||||
*/
|
*/
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class GlobalErrorController {
|
public class GlobalErrorController {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(GlobalErrorController.class);
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
@ExceptionHandler(Throwable.class)
|
@ExceptionHandler(Throwable.class)
|
||||||
public String errorHandler(Throwable throwable) {
|
public String errorHandler(Throwable throwable) {
|
||||||
|
logger.error("Error", throwable);
|
||||||
return throwable.getMessage();
|
return throwable.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user