@@ -231,28 +231,32 @@ private Map<String, Object> createArgsDictionary() {
231231 }
232232
233233 private void saveRequestForLater (Map <String , Object > args ) {
234- synchronized (Request .class ) {
235- Context context = Leanplum .getContext ();
236- SharedPreferences preferences = context .getSharedPreferences (
237- LEANPLUM , Context .MODE_PRIVATE );
238- SharedPreferences .Editor editor = preferences .edit ();
239- long count = LeanplumEventDataManager .getEventsCount ();
240- String uuid = preferences .getString (Constants .Defaults .UUID_KEY , null );
241- if (uuid == null || count % MAX_EVENTS_PER_API_CALL == 0 ) {
242- uuid = UUID .randomUUID ().toString ();
243- editor .putString (Constants .Defaults .UUID_KEY , uuid );
244- SharedPreferencesUtil .commitChanges (editor );
245- }
246- args .put (UUID_KEY , uuid );
247- LeanplumEventDataManager .insertEvent (JsonConverter .toJson (args ));
248-
249- dataBaseIndex = count ;
250- // Checks if here response and/or error callback for this request. We need to add callbacks to
251- // eventCallbackManager only if here was internet connection, otherwise triggerErrorCallback
252- // will handle error callback for this event.
253- if (response != null || error != null && !Util .isConnected ()) {
254- eventCallbackManager .addCallbacks (this , response , error );
234+ try {
235+ synchronized (Request .class ) {
236+ Context context = Leanplum .getContext ();
237+ SharedPreferences preferences = context .getSharedPreferences (
238+ LEANPLUM , Context .MODE_PRIVATE );
239+ SharedPreferences .Editor editor = preferences .edit ();
240+ long count = LeanplumEventDataManager .getEventsCount ();
241+ String uuid = preferences .getString (Constants .Defaults .UUID_KEY , null );
242+ if (uuid == null || count % MAX_EVENTS_PER_API_CALL == 0 ) {
243+ uuid = UUID .randomUUID ().toString ();
244+ editor .putString (Constants .Defaults .UUID_KEY , uuid );
245+ SharedPreferencesUtil .commitChanges (editor );
246+ }
247+ args .put (UUID_KEY , uuid );
248+ LeanplumEventDataManager .insertEvent (JsonConverter .toJson (args ));
249+
250+ dataBaseIndex = count ;
251+ // Checks if here response and/or error callback for this request. We need to add callbacks to
252+ // eventCallbackManager only if here was internet connection, otherwise triggerErrorCallback
253+ // will handle error callback for this event.
254+ if (response != null || error != null && !Util .isConnected ()) {
255+ eventCallbackManager .addCallbacks (this , response , error );
256+ }
255257 }
258+ } catch (Throwable t ) {
259+ Util .handleException (t );
256260 }
257261 }
258262
0 commit comments