Skip to content

Commit e44fe24

Browse files
committed
Add exception print statements. Might remove later.
1 parent e0342ba commit e44fe24

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

core/src/main/java/com/github/fernthedev/fernapi/universal/mysql/DatabaseListener.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import com.github.fernthedev.fernapi.universal.data.chat.ChatColor;
88
import com.github.fernthedev.fernapi.universal.data.database.*;
99
import com.github.fernthedev.fernapi.universal.exceptions.database.DatabaseException;
10-
import lombok.AccessLevel;
11-
import lombok.Getter;
12-
import lombok.NonNull;
13-
import lombok.Setter;
10+
import lombok.*;
1411
import org.intellij.lang.annotations.Language;
1512
import org.panteleyev.mysqlapi.MySqlProxy;
1613
import org.panteleyev.mysqlapi.annotations.Column;
@@ -144,7 +141,7 @@ public CompletableFuture<List<DbRow>> getTableRows(String name) {
144141
@Language("SQL") String sql = "SELECT * FROM " + name + ";";
145142
Universal.debug(ChatColor.GREEN + "Executing {}", sql);
146143

147-
return database.getResultsAsync(sql);
144+
return database.getResultsAsync(sql).handle(this::handleException);
148145
}
149146

150147
/**
@@ -167,7 +164,7 @@ public <T extends RowData> CompletableFuture<Void> removeRowIfColumnContainsValu
167164
} catch (SQLException throwables) {
168165
throwables.printStackTrace();
169166
}
170-
});
167+
}).handle(this::handleException);
171168

172169
}
173170

@@ -200,7 +197,7 @@ public <T extends RowData> CompletableFuture<Integer> insertIntoTable(TableInfo<
200197
}
201198

202199
return dbStatement;
203-
});
200+
}).handle(this::handleException);
204201

205202
}
206203

@@ -224,7 +221,7 @@ public <T extends RowData> CompletableFuture<Integer> updateRow(TableInfo<T> tab
224221
Universal.debug(ChatColor.GREEN + "Fully Executed {} {} ({}) {} {}", sql, tableInfo.getTableName(), columnValues, conditionKey, conditionValue);
225222
tableInfo.loadFromDB(DatabaseListener.this);
226223
return integer;
227-
});
224+
}).handle(this::handleException);
228225

229226

230227
}
@@ -239,7 +236,7 @@ public <T extends RowData> CompletableFuture<Integer> removeTable(TableInfo<T> t
239236

240237
Universal.debug("Executing {}", sql);
241238

242-
return database.executeUpdateAsync(sql);
239+
return database.executeUpdateAsync(sql).handle(this::handleException);
243240
}
244241

245242
/**
@@ -398,7 +395,7 @@ public <T extends RowData> CompletableFuture<Void> createTable(@NonNull TableInf
398395
}
399396

400397
tableDataInfo.loadFromDB(DatabaseListener.this);
401-
});
398+
}).handle(this::handleException);
402399

403400

404401
}
@@ -407,4 +404,14 @@ protected Logger getLogger() {
407404
return Universal.getMethods().getAbstractLogger();
408405
}
409406

407+
@SneakyThrows
408+
protected <T> T handleException(T t, Throwable throwable) {
409+
if (throwable != null) {
410+
Universal.getLogger().error(throwable.getMessage(), t);
411+
throw throwable;
412+
}
413+
414+
return t;
415+
}
416+
410417
}

0 commit comments

Comments
 (0)