mirror of
https://github.com/FabricMC/fabric-loom.git
synced 2025-09-04 11:04:03 +00:00
Update loom native, with better error handling. (#1102)
This commit is contained in:
@@ -12,7 +12,7 @@ mapping-io = "0.5.1"
|
||||
lorenz-tiny = "4.0.2"
|
||||
mercury = "0.4.1"
|
||||
kotlinx-metadata = "0.9.0"
|
||||
loom-native = "0.1.1"
|
||||
loom-native = "0.2.0"
|
||||
|
||||
# Plugins
|
||||
spotless = "6.25.0"
|
||||
|
@@ -32,10 +32,15 @@ import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.fabricmc.loom.nativeplatform.LoomNativePlatform;
|
||||
import net.fabricmc.loom.nativeplatform.LoomNativePlatformException;
|
||||
|
||||
public final class ExceptionUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionUtil.class);
|
||||
|
||||
/**
|
||||
* Creates a descriptive user-facing wrapper exception for an underlying cause.
|
||||
*
|
||||
@@ -74,7 +79,14 @@ public final class ExceptionUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<ProcessHandle> processes = LoomNativePlatform.getProcessesWithLockOn(path);
|
||||
final List<ProcessHandle> processes;
|
||||
|
||||
try {
|
||||
processes = LoomNativePlatform.getProcessesWithLockOn(path);
|
||||
} catch (LoomNativePlatformException e) {
|
||||
LOGGER.error("{}, Failed to query processes holding a lock on {}", e.getMessage(), path);
|
||||
return;
|
||||
}
|
||||
|
||||
if (processes.isEmpty()) {
|
||||
return;
|
||||
|
@@ -31,11 +31,15 @@ import java.util.StringJoiner;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.logging.LogLevel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.fabricmc.loom.nativeplatform.LoomNativePlatform;
|
||||
import net.fabricmc.loom.nativeplatform.LoomNativePlatformException;
|
||||
|
||||
public record ProcessUtil(LogLevel logLevel) {
|
||||
private static final String EXPLORER_COMMAND = "C:\\Windows\\explorer.exe";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ProcessUtil.class);
|
||||
|
||||
public static ProcessUtil create(Project project) {
|
||||
return new ProcessUtil(project.getGradle().getStartParameter().getLogLevel());
|
||||
@@ -92,7 +96,14 @@ public record ProcessUtil(LogLevel logLevel) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
List<String> titles = LoomNativePlatform.getWindowTitlesForPid(processHandle.pid());
|
||||
List<String> titles;
|
||||
|
||||
try {
|
||||
titles = LoomNativePlatform.getWindowTitlesForPid(processHandle.pid());
|
||||
} catch (LoomNativePlatformException e) {
|
||||
LOGGER.error("{}, Failed to query window title for pid {}", e.getMessage(), processHandle.pid());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (titles.isEmpty()) {
|
||||
return Optional.empty();
|
||||
|
Reference in New Issue
Block a user