mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-03 05:57:42 -05:00
Update loom native, with better error handling. (#1102)
This commit is contained in:
@@ -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