diff --git a/src/main/java/org/olat/core/gui/exception/ExceptionWindowController.java b/src/main/java/org/olat/core/gui/exception/ExceptionWindowController.java index 0bdc0343bdc0b9d04aa53abfb627e959a0e77e16..ff58c521600ccc25e872df612e1a39cdbe1e0d7c 100644 --- a/src/main/java/org/olat/core/gui/exception/ExceptionWindowController.java +++ b/src/main/java/org/olat/core/gui/exception/ExceptionWindowController.java @@ -30,6 +30,7 @@ package org.olat.core.gui.exception; import java.util.Date; import java.util.List; +import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurityModule; import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; @@ -62,6 +63,8 @@ import org.olat.core.util.UserSession; import org.olat.core.util.Util; import org.olat.core.util.WebappHelper; import org.olat.core.util.i18n.I18nManager; +import org.olat.core.util.mail.MailBundle; +import org.olat.core.util.mail.MailManager; /** * Description: <br> @@ -235,6 +238,35 @@ public class ExceptionWindowController extends DefaultChiefController { w.setContentPane(msg); setWindow(w); + + // send email to support address + try { + // if null, user may crashed before getting a valid session, try with + // guest user instead + if (curIdent == null) { + BaseSecurity im = CoreSpringFactory.getImpl(BaseSecurity.class); + curIdent = im.findIdentityByName("guest"); + } + + MailBundle bundle = new MailBundle(); + bundle.setFromId(curIdent); + bundle.setTo(WebappHelper.getMailConfig("mailError")); + bundle.setContent( + "**RedScreen** Nr.: " + Settings.getNodeInfo() + "-E" + refNum, + "**RedScreen** " + o3e.getLogMsg() + "\n" + + formatter.formatDateAndTime(new Date()) + "\n" + + "Username: " + curIdent.getName() + "\n" + + "Stacktrace:\n" + + OLATRuntimeException.throwableToHtml(th).replaceAll("<br />", "\n") + "\n\n" + + "ListenerInfo\n" + + componentListenerInfo + "\n" + + "Last businesspath: " + msg.contextGet("lastbusinesspath") + "\n" + + "Prev businesspath: " + msg.contextGet("prevbusinesspath") + "\n" + ); + CoreSpringFactory.getImpl(MailManager.class).sendExternMessage(bundle, null, false); + } catch (Exception e) { + log.error("Failed to send RedScreen-data via mail", e); + } } @Override