From 878a0407089fe955984468b1102cc377ec3ec21d Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 28 Aug 2012 01:34:15 -0300 Subject: [PATCH] Extends exception info ... --- .../java/com/wisemapping/rest/BaseController.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java index 464b3b0d..3f0944b3 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java @@ -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(); }