IdeaLoggingEvent (Object messageObject, Throwable throwable) { String message = null; List<ExceptionWithAttachments> withAttachments = ExceptionUtil.findCauseAndSuppressed(throwable, ExceptionWithAttachments.class); if (!withAttachments.isEmpty() && withAttachments.get(0) instanceof RuntimeExceptionWithAttachments) { message = ((RuntimeExceptionWithAttachments)withAttachments.get(0)).getUserMessage(); } if (message == null && messageObject != null) { message = messageObject.toString(); } if (withAttachments.isEmpty()) { return new IdeaLoggingEvent(message, throwable); } else { List<Attachment> list = new ArrayList<>(); for (ExceptionWithAttachments e : withAttachments) { Collections.addAll(list, e.getAttachments()); } return LogMessage.eventOf(throwable, message, list); } }