Change error reporting subject.

This commit is contained in:
Paulo Gustavo Veiga 2012-08-26 19:45:12 -03:00
parent 81af279e21
commit 1265d978e8
2 changed files with 13 additions and 6 deletions

View File

@ -150,20 +150,22 @@ final public class NotificationService {
// } // }
} }
public void reportMindmapEditorError(@NotNull Mindmap mindmap, @NotNull User user, @NotNull String userAgent, @Nullable String jsErrorMsg) { public void reportMindmapEditorError(@NotNull Mindmap mindmap, @Nullable User user, @NotNull String userAgent, @Nullable String jsErrorMsg) {
try { try {
final Map<String, Object> model = new HashMap<String, Object>(); final Map<String, Object> model = new HashMap<String, Object>();
model.put("user", user); model.put("user", user);
model.put("email", (user != null ? user.getEmail() : "'anonymous'"));
model.put("errorMsg", jsErrorMsg); model.put("errorMsg", jsErrorMsg);
model.put("mapXML", mindmap.getXmlStr().replaceAll("<", "&lt;")); model.put("mapXML", mindmap.getXmlStr().replaceAll("<", "&lt;"));
model.put("mapId", mindmap.getId()); model.put("mapId", mindmap.getId());
model.put("mapTitle", mindmap.getTitle()); model.put("mapTitle", mindmap.getTitle());
model.put("userAgent", userAgent); model.put("userAgent", userAgent);
model.put("details", "Editor");
final String errorReporterEmail = mailer.getErrorReporterEmail(); final String errorReporterEmail = mailer.getErrorReporterEmail();
if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) { if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) {
mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Editor error from " + user.getEmail(), model, mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Bug from '" + (user != null ? user.getEmail() + "'" : "'anonymous'"), model,
"errorNotification.vm"); "errorNotification.vm");
} }
} catch (Exception e) { } catch (Exception e) {
@ -171,17 +173,19 @@ final public class NotificationService {
} }
} }
public void reportMindmapExportError(@NotNull String exportContent, @NotNull User user, @NotNull String userAgent, @NotNull Throwable exception) { public void reportMindmapExportError(@NotNull String exportContent, @Nullable User user, @Nullable String userAgent, @NotNull Throwable exception) {
try { try {
final Map<String, Object> model = new HashMap<String, Object>(); final Map<String, Object> model = new HashMap<String, Object>();
model.put("user", user); model.put("user", user);
model.put("email", (user != null ? user.getEmail() : "'anonymous'"));
model.put("errorMsg", stackTraceToString(exception)); model.put("errorMsg", stackTraceToString(exception));
model.put("mapXML", exportContent.replaceAll("<", "&lt;")); model.put("mapXML", exportContent.replaceAll("<", "&lt;"));
model.put("userAgent", userAgent); model.put("userAgent", userAgent);
model.put("details", "Export");
final String errorReporterEmail = mailer.getErrorReporterEmail(); final String errorReporterEmail = mailer.getErrorReporterEmail();
if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) { if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) {
mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Export error from " + user.getEmail(), model, mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Bug from '" + (user != null ? user.getEmail() + "'" : "'anonymous'"), model,
"errorNotification.vm"); "errorNotification.vm");
} }
} catch (Exception e) { } catch (Exception e) {
@ -193,12 +197,14 @@ final public class NotificationService {
try { try {
final Map<String, Object> model = new HashMap<String, Object>(); final Map<String, Object> model = new HashMap<String, Object>();
model.put("user", user); model.put("user", user);
model.put("email", (user != null ? user.getEmail() : "'anonymous'"));
model.put("errorMsg", stackTraceToString(exception)); model.put("errorMsg", stackTraceToString(exception));
model.put("userAgent", userAgent); model.put("userAgent", userAgent);
model.put("details", "Unexpected");
final String errorReporterEmail = mailer.getErrorReporterEmail(); final String errorReporterEmail = mailer.getErrorReporterEmail();
if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) { if (errorReporterEmail != null && !errorReporterEmail.isEmpty()) {
mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Unexpected error from " + (user != null ? user.getEmail() : "anonymous"), model, mailer.sendEmail(mailer.getServerSenderEmail(), errorReporterEmail, "[WiseMapping] Bug from '" + (user != null ? user.getEmail() + "'" : "'anonymous'"), model,
"errorNotification.vm"); "errorNotification.vm");
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -1,8 +1,9 @@
<html> <html>
<body> <body>
<ul> <ul>
<li>Details: ${details}</li>
<li>User Name: ${user.fullName}</li> <li>User Name: ${user.fullName}</li>
<li>Email: ${user.email}</li> <li>Email: ${email}</li>
<li>User Agent: ${userAgent}</li> <li>User Agent: ${userAgent}</li>
#if($mapId) #if($mapId)
<li>Mindmap Id: ${mapId}</li> <li>Mindmap Id: ${mapId}</li>