Extends exception info ...

This commit is contained in:
Paulo Gustavo Veiga 2012-08-28 01:34:15 -03:00
parent 1555560415
commit 878a040708

View File

@ -18,6 +18,7 @@
package com.wisemapping.rest;
import com.wisemapping.filter.UserAgent;
import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestErrors;
@ -30,6 +31,11 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.support.RequestContextUtils;
import org.springframework.web.util.WebUtils;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
public class BaseController {
@ -37,6 +43,9 @@ public class BaseController {
@Autowired
private ResourceBundleMessageSource messageSource;
@Autowired
ServletContext context;
@Autowired
private NotificationService notificationService;
@ -51,9 +60,9 @@ public class BaseController {
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public String handleServerErrors(@NotNull Exception ex) {
public String handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) {
final User user = Utils.getUser();
notificationService.reportUnexpectedError(ex, user, "unknown browser");
notificationService.reportUnexpectedError(ex, user, request.getHeader(UserAgent.USER_AGENT_HEADER));
return ex.getMessage();
}