Search in sources :

Example 1 with ExceptionReportService

use of com.haulmont.cuba.core.app.ExceptionReportService in project cuba by cuba-platform.

the class JXErrorPaneExt method sendSupportEmail.

private void sendSupportEmail(ErrorInfo jXErrorPaneInfo) {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    ExceptionReportService reportService = AppBeans.get(ExceptionReportService.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    TopLevelFrame mainFrame = App.getInstance().getMainFrame();
    Messages messages = AppBeans.get(Messages.NAME);
    Locale locale = App.getInstance().getLocale();
    try {
        TimeSource timeSource = AppBeans.get(TimeSource.NAME);
        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeSource.currentTimestamp());
        UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
        User user = userSessionSource.getUserSession().getUser();
        Map<String, Object> binding = new HashMap<>();
        binding.put("timestamp", date);
        binding.put("errorMessage", jXErrorPaneInfo.getBasicErrorMessage());
        binding.put("stacktrace", getStackTrace(jXErrorPaneInfo.getErrorException()));
        binding.put("systemId", clientConfig.getSystemID());
        binding.put("userLogin", user.getLogin());
        if (MapUtils.isNotEmpty(additionalExceptionReportBinding)) {
            binding.putAll(additionalExceptionReportBinding);
        }
        reportService.sendExceptionReport(clientConfig.getSupportEmail(), ImmutableMap.copyOf(binding));
        mainFrame.showNotification(messages.getMainMessage("errorPane.emailSent", locale), Frame.NotificationType.TRAY);
    } catch (Throwable e) {
        mainFrame.showNotification(messages.getMainMessage("errorPane.emailSendingErr", locale), Frame.NotificationType.ERROR);
        log.error("Can't send error report", e);
    }
}
Also used : Locale(java.util.Locale) User(com.haulmont.cuba.security.entity.User) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) HashMap(java.util.HashMap) ExceptionReportService(com.haulmont.cuba.core.app.ExceptionReportService) ClientConfig(com.haulmont.cuba.client.ClientConfig) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

ClientConfig (com.haulmont.cuba.client.ClientConfig)1 ExceptionReportService (com.haulmont.cuba.core.app.ExceptionReportService)1 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)1 User (com.haulmont.cuba.security.entity.User)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1