/** * Creates a Sentry exception based on a Java Throwable. * <p> * The {@code childExceptionStackTrace} parameter is used to define the common frames with the child exception * (Exception caused by {@code throwable}). * * @param throwable Java exception to send to Sentry. * @param childExceptionStackTrace StackTrace of the exception caused by {@code throwable}. */ public SentryException(Throwable throwable, StackTraceElement[] childExceptionStackTrace) { this.exceptionMessage = throwable.getMessage(); this.exceptionClassName = throwable.getClass().getSimpleName(); Package exceptionPackage = throwable.getClass().getPackage(); this.exceptionPackageName = exceptionPackage != null ? exceptionPackage.getName() : null; this.stackTraceInterface = new StackTraceInterface( throwable.getStackTrace(), childExceptionStackTrace, FrameCache.get(throwable)); }
@Override public void writeInterface(JsonGenerator generator, StackTraceInterface stackTraceInterface) throws IOException { generator.writeStartObject(); generator.writeArrayFieldStart(FRAMES_PARAMETER); SentryStackTraceElement[] sentryStackTrace = stackTraceInterface.getStackTrace(); int commonWithEnclosing = stackTraceInterface.getFramesCommonWithEnclosing(); for (int i = sentryStackTrace.length - 1; i >= 0; i--) { writeFrame(generator, sentryStackTrace[i], commonWithEnclosing-- > 0); } generator.writeEndArray(); generator.writeEndObject(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SentryException that = (SentryException) o; if (!exceptionClassName.equals(that.exceptionClassName)) { return false; } if (exceptionMessage != null ? !exceptionMessage.equals(that.exceptionMessage) : that.exceptionMessage != null) { return false; } if (exceptionPackageName != null ? !exceptionPackageName.equals(that.exceptionPackageName) : that.exceptionPackageName != null) { return false; } return stackTraceInterface.equals(that.stackTraceInterface); }
Deque<SentryException> throwables = ((ExceptionInterface) sentryInterface).getExceptions(); for (SentryException throwable : throwables) { for (SentryStackTraceElement traceElement : throwable.getStackTraceInterface().getStackTrace()) { String plugin = PluginClassloader.getPluginWhichLoaded(traceElement.getModule()); if (plugin != null) { this.client.sendException(this.exception); } else if (this.stacktrace != null) { this.client.addBuilderHelper(eventBuilder -> eventBuilder.withSentryInterface(new StackTraceInterface(this.stacktrace))); this.client.sendMessage(message == null ? "Nulled message" : message); } else {
} else if (event.getSource() != null) { StackTraceElement[] stackTrace = {event.getSource()}; eventBuilder.withSentryInterface(new StackTraceInterface(stackTrace));