mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 03:27:37 +01:00
Replaced interface in WebExceptionLogger with a more generic one
This commit is contained in:
parent
24bab50367
commit
3824741b5d
@ -5,6 +5,7 @@
|
||||
package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.utilities.java.ThrowingVoidFunction;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -19,9 +20,9 @@ import java.util.Map;
|
||||
*/
|
||||
public class WebExceptionLogger {
|
||||
|
||||
public static void logIfOccurs(Class c, ExceptionLoggingAction action) {
|
||||
public static void logIfOccurs(Class c, ThrowingVoidFunction<WebException> function) {
|
||||
try {
|
||||
action.performAction();
|
||||
function.apply();
|
||||
} catch (ConnectionFailException e) {
|
||||
if (shouldLog(e)) {
|
||||
Log.warn(e.getMessage());
|
||||
@ -62,10 +63,4 @@ public class WebExceptionLogger {
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface ExceptionLoggingAction {
|
||||
|
||||
void performAction() throws WebException;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.djrapitops.plan.utilities.java;
|
||||
|
||||
/**
|
||||
* Functional interface that performs an operation that might throw an exception.
|
||||
* <p>
|
||||
* Follows naming scheme of Java 8 functional interfaces.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface ThrowingVoidFunction<T extends Throwable> {
|
||||
|
||||
void apply() throws T;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user