mirror of
https://github.com/jie65535/gc-opencommand-plugin.git
synced 2025-06-02 17:49:12 +08:00
Capture Request Exception
This commit is contained in:
parent
f19c4b8e77
commit
82477321d1
@ -50,6 +50,7 @@ public final class OpenCommandHandler implements Router {
|
|||||||
|
|
||||||
public static void handle(Context context) {
|
public static void handle(Context context) {
|
||||||
var plugin = OpenCommandPlugin.getInstance();
|
var plugin = OpenCommandPlugin.getInstance();
|
||||||
|
try {
|
||||||
var config = plugin.getConfig();
|
var config = plugin.getConfig();
|
||||||
var data = plugin.getData();
|
var data = plugin.getData();
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
@ -177,6 +178,9 @@ public final class OpenCommandHandler implements Router {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.json(new JsonResponse(403, "forbidden"));
|
context.json(new JsonResponse(403, "forbidden"));
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
plugin.getLogger().error("[OpenCommand] handler error.", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cleanupExpiredCodes() {
|
private static void cleanupExpiredCodes() {
|
||||||
|
@ -51,6 +51,7 @@ public final class OpenCommandOnlyHttpHandler implements Router {
|
|||||||
|
|
||||||
public static void handle(Context context) {
|
public static void handle(Context context) {
|
||||||
var plugin = OpenCommandPlugin.getInstance();
|
var plugin = OpenCommandPlugin.getInstance();
|
||||||
|
try {
|
||||||
var config = plugin.getConfig();
|
var config = plugin.getConfig();
|
||||||
var data = plugin.getData();
|
var data = plugin.getData();
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
@ -200,6 +201,9 @@ public final class OpenCommandOnlyHttpHandler implements Router {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.json(new JsonResponse(403, "forbidden"));
|
context.json(new JsonResponse(403, "forbidden"));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
plugin.getLogger().error("[OpenCommand] handler error.", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cleanupExpiredCodes() {
|
private static void cleanupExpiredCodes() {
|
||||||
|
@ -111,9 +111,11 @@ public final class OpenCommandPlugin extends Plugin {
|
|||||||
config = JsonUtils.decode(Files.readString(configFile.toPath(), StandardCharsets.UTF_8),
|
config = JsonUtils.decode(Files.readString(configFile.toPath(), StandardCharsets.UTF_8),
|
||||||
OpenCommandConfig.class);
|
OpenCommandConfig.class);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
config = new OpenCommandConfig();
|
|
||||||
getLogger().error("[OpenCommand] There was an error while trying to load the configuration from config.json. Please make sure that there are no syntax errors. If you want to start with a default configuration, delete your existing config.json.");
|
getLogger().error("[OpenCommand] There was an error while trying to load the configuration from config.json. Please make sure that there are no syntax errors. If you want to start with a default configuration, delete your existing config.json.");
|
||||||
}
|
}
|
||||||
|
if (config == null) {
|
||||||
|
config = new OpenCommandConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
runMode = Grasscutter.getConfig().server.runMode;
|
runMode = Grasscutter.getConfig().server.runMode;
|
||||||
@ -132,9 +134,11 @@ public final class OpenCommandPlugin extends Plugin {
|
|||||||
data = JsonUtils.decode(Files.readString(dataFile.toPath(), StandardCharsets.UTF_8),
|
data = JsonUtils.decode(Files.readString(dataFile.toPath(), StandardCharsets.UTF_8),
|
||||||
OpenCommandData.class);
|
OpenCommandData.class);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
data = new OpenCommandData();
|
|
||||||
getLogger().error("[OpenCommand] There was an error while trying to load the data from data.json. Please make sure that there are no syntax errors. If you want to start with a default data, delete your existing data.json.");
|
getLogger().error("[OpenCommand] There was an error while trying to load the data from data.json. Please make sure that there are no syntax errors. If you want to start with a default data, delete your existing data.json.");
|
||||||
}
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = new OpenCommandData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user