File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
sentry/src/main/java/io/sentry Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ public class SentryOptions {
179179 */
180180 private @ Nullable BeforeBreadcrumbCallback beforeBreadcrumb ;
181181
182- /** Invoked when some payload sent from the SDK is dropped before consumed by Sentry, */
182+ /** Invoked when some data from the SDK is dropped before being consumed by Sentry */
183183 private @ Nullable OnDiscardCallback onDiscard ;
184184
185185 /** The cache dir. path for caching offline events */
Original file line number Diff line number Diff line change @@ -125,7 +125,16 @@ private void recordLostEventInternal(
125125 final ClientReportKey key = new ClientReportKey (reason , category );
126126 storage .addCount (key , countToAdd );
127127 if (options .getOnDiscard () != null ) {
128- options .getOnDiscard ().execute (reason , category , countToAdd );
128+ try {
129+ options .getOnDiscard ().execute (reason , category , countToAdd );
130+ } catch (Throwable e ) {
131+ options
132+ .getLogger ()
133+ .log (
134+ SentryLevel .ERROR ,
135+ "The onDiscard callback threw an exception. It will be added as breadcrumb and continue." ,
136+ e );
137+ }
129138 }
130139 }
131140
You can’t perform that action at this time.
0 commit comments