@@ -206,11 +206,19 @@ public void insert(@NonNull String table, @Nullable String nullColumnHack, @Null
206
206
writableDb .beginTransaction ();
207
207
writableDb .insert (table , nullColumnHack , values );
208
208
writableDb .setTransactionSuccessful ();
209
+ } catch (SQLiteException e ) {
210
+ logger .error ("Error inserting on table: " + table + " with nullColumnHack: " + nullColumnHack + " and values: " + values , e );
211
+ } catch (IllegalStateException e ) {
212
+ logger .error ("Error under inserting transaction under table: " + table + " with nullColumnHack: " + nullColumnHack + " and values: " + values , e );
209
213
} finally {
210
- try {
211
- writableDb .endTransaction (); // May throw if transaction was never opened or DB is full.
212
- } catch (SQLException e ) {
213
- logger .error ("Error closing transaction! " , e );
214
+ if (writableDb != null ) {
215
+ try {
216
+ writableDb .endTransaction (); // May throw if transaction was never opened or DB is full.
217
+ } catch (IllegalStateException e ) {
218
+ logger .error ("Error closing transaction! " , e );
219
+ } catch (SQLiteException e ) {
220
+ logger .error ("Error closing transaction! " , e );
221
+ }
214
222
}
215
223
}
216
224
}
@@ -225,14 +233,18 @@ public void insertOrThrow(@NonNull String table, @Nullable String nullColumnHack
225
233
writableDb .beginTransaction ();
226
234
writableDb .insertOrThrow (table , nullColumnHack , values );
227
235
writableDb .setTransactionSuccessful ();
228
- } catch (Throwable t ) {
229
- OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , "Error inserting under table: " + table , t );
236
+ } catch (SQLiteException e ) {
237
+ logger .error ("Error inserting or throw on table: " + table + " with nullColumnHack: " + nullColumnHack + " and values: " + values , e );
238
+ } catch (IllegalStateException e ) {
239
+ logger .error ("Error under inserting or throw transaction under table: " + table + " with nullColumnHack: " + nullColumnHack + " and values: " + values , e );
230
240
} finally {
231
241
if (writableDb != null ) {
232
242
try {
233
243
writableDb .endTransaction (); // May throw if transaction was never opened or DB is full.
234
- } catch (Throwable t ) {
235
- OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , "Error closing transaction! " , t );
244
+ } catch (IllegalStateException e ) {
245
+ logger .error ("Error closing transaction! " , e );
246
+ } catch (SQLiteException e ) {
247
+ logger .error ("Error closing transaction! " , e );
236
248
}
237
249
}
238
250
}
@@ -242,20 +254,27 @@ public void insertOrThrow(@NonNull String table, @Nullable String nullColumnHack
242
254
@ Override
243
255
public int update (@ NonNull String table , @ NonNull ContentValues values , @ Nullable String whereClause , @ Nullable String [] whereArgs ) {
244
256
int result = 0 ;
257
+ if (values == null || values .toString ().isEmpty ())
258
+ return result ;
259
+
245
260
synchronized (LOCK ) {
246
261
SQLiteDatabase writableDb = getSQLiteDatabaseWithRetries ();
247
262
try {
248
263
writableDb .beginTransaction ();
249
264
result = writableDb .update (table , values , whereClause , whereArgs );
250
265
writableDb .setTransactionSuccessful ();
251
- } catch (Throwable t ) {
252
- OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , "Error updating table: " + table , t );
266
+ } catch (SQLiteException e ) {
267
+ logger .error ("Error updating on table: " + table + " with whereClause: " + whereClause + " and whereArgs: " + whereArgs , e );
268
+ } catch (IllegalStateException e ) {
269
+ logger .error ("Error under update transaction under table: " + table + " with whereClause: " + whereClause + " and whereArgs: " + whereArgs , e );
253
270
} finally {
254
271
if (writableDb != null ) {
255
272
try {
256
273
writableDb .endTransaction (); // May throw if transaction was never opened or DB is full.
257
- } catch (Throwable t ) {
258
- OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , "Error closing transaction! " , t );
274
+ } catch (IllegalStateException e ) {
275
+ logger .error ("Error closing transaction! " , e );
276
+ } catch (SQLiteException e ) {
277
+ logger .error ("Error closing transaction! " , e );
259
278
}
260
279
}
261
280
}
@@ -272,11 +291,15 @@ public void delete(@NonNull String table, @Nullable String whereClause, @Nullabl
272
291
writableDb .delete (table , whereClause , whereArgs );
273
292
writableDb .setTransactionSuccessful ();
274
293
} catch (SQLiteException e ) {
275
- logger .error ("Error deleting on table: " + table , e );
294
+ logger .error ("Error deleting on table: " + table + " with whereClause: " + whereClause + " and whereArgs: " + whereArgs , e );
295
+ } catch (IllegalStateException e ) {
296
+ logger .error ("Error under delete transaction under table: " + table + " with whereClause: " + whereClause + " and whereArgs: " + whereArgs , e );
276
297
} finally {
277
298
if (writableDb != null ) {
278
299
try {
279
300
writableDb .endTransaction (); // May throw if transaction was never opened or DB is full.
301
+ } catch (IllegalStateException e ) {
302
+ logger .error ("Error closing transaction! " , e );
280
303
} catch (SQLiteException e ) {
281
304
logger .error ("Error closing transaction! " , e );
282
305
}
0 commit comments