1
0
forked from Clones/Controlify

🐛 Catch errors with controller detection, so they still load on failure

This commit is contained in:
isXander
2023-08-06 23:28:04 +01:00
parent 2069f1ab6d
commit 372cfa69c3
2 changed files with 11 additions and 3 deletions

View File

@ -116,7 +116,7 @@ public class Controlify implements ControlifyApi {
this.onControllerDisconnect(jid);
}
});
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
}
});
@ -203,7 +203,7 @@ public class Controlify implements ControlifyApi {
FabricLoader.getInstance().getEntrypoints("controlify", ControlifyEntrypoint.class).forEach(entrypoint -> {
try {
entrypoint.onControllersDiscovered(this);
} catch (Exception e) {
} catch (Throwable e) {
Log.LOGGER.error("Failed to run `onControllersDiscovered` on Controlify entrypoint: " + entrypoint.getClass().getName(), e);
}
});

View File

@ -48,13 +48,21 @@ public class ControllerHIDService {
}
public ControllerHIDInfo fetchType(int jid) {
ControllerHIDInfo info = fetchType0(jid);
ControllerHIDInfo info;
try {
info = fetchType0(jid);
} catch (Throwable e) {
Log.LOGGER.error("Failed to fetch controller type!", e);
info = new ControllerHIDInfo(ControllerType.UNKNOWN, Optional.empty());
}
if (DebugProperties.PRINT_VID_PID) {
info.hidDevice.ifPresent(hid -> {
var hex = HexFormat.of().withPrefix("0x");
Log.LOGGER.info("VID: {}, PID: {}", hex.toHexDigits(hid.vendorID()), hex.toHexDigits(hid.productID()));
});
}
return info;
}