add log
This commit is contained in:
parent
5c69fb1e62
commit
6d4cc0534f
|
@ -2,9 +2,11 @@ package org.bench4q.master.api;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.master.auth.AuthenticationManager;
|
import org.bench4q.master.auth.AuthenticationManager;
|
||||||
import org.bench4q.master.entity.User;
|
import org.bench4q.master.entity.User;
|
||||||
import org.bench4q.master.exception.Bench4QException;
|
import org.bench4q.master.exception.Bench4QException;
|
||||||
|
import org.bench4q.master.exception.ExceptionLog;
|
||||||
import org.bench4q.share.models.ErrorResponseModel;
|
import org.bench4q.share.models.ErrorResponseModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -17,6 +19,7 @@ public abstract class BaseController {
|
||||||
private AuthenticationManager authenticationManager;
|
private AuthenticationManager authenticationManager;
|
||||||
protected static final String HAVE_NO_POWER = "Have no power";
|
protected static final String HAVE_NO_POWER = "Have no power";
|
||||||
protected static final String EXCEPTION_HAPPEND = "Exception happened";
|
protected static final String EXCEPTION_HAPPEND = "Exception happened";
|
||||||
|
private Logger logger = Logger.getLogger(BaseController.class);
|
||||||
|
|
||||||
protected HttpServletRequest getRequest() {
|
protected HttpServletRequest getRequest() {
|
||||||
return request;
|
return request;
|
||||||
|
@ -49,6 +52,7 @@ public abstract class BaseController {
|
||||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ErrorResponseModel handleException(RuntimeException e) {
|
public ErrorResponseModel handleException(RuntimeException e) {
|
||||||
|
logger.info(ExceptionLog.getStackTrace(e));
|
||||||
return ErrorResponseModel.buildErrorResponse("RUNTIME_EXCEPTION",
|
return ErrorResponseModel.buildErrorResponse("RUNTIME_EXCEPTION",
|
||||||
e.getMessage(), "");
|
e.getMessage(), "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue