Skip to content

Commit

Permalink
Specify full entrypoint name on crash (#928)
Browse files Browse the repository at this point in the history
* Specify full entrypoint name on crash

* Default getEntrypointName for EntrypointContainer

* Rephrased entrypoint exception message
  • Loading branch information
SHsuperCM authored Aug 15, 2024
1 parent f6d496a commit 12dd25f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ public interface EntrypointContainer<T> {
* Returns the mod that provided this entrypoint.
*/
ModContainer getProvider();

/**
* Returns a string representation of the entrypoint's definition.
*/
default String getDefinition() {
return "";
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ public <T> void invokeEntrypoints(String key, Class<T> type, Consumer<? super T>
} catch (Throwable t) {
exception = ExceptionUtil.gatherExceptions(t,
exception,
exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s'!",
key, container.getProvider().getMetadata().getId()),
exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s' at '%s'!",
key, container.getProvider().getMetadata().getId(), container.getDefinition()),
exc));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ public synchronized T getEntrypoint() {
public ModContainer getProvider() {
return entry.getModContainer();
}

@Override
public String getDefinition() {
return entry.getDefinition();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ interface Entry {
boolean isOptional();

ModContainerImpl getModContainer();

String getDefinition();
}

@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -87,6 +89,11 @@ public boolean isOptional() {
public ModContainerImpl getModContainer() {
return mod;
}

@Override
public String getDefinition() {
return value;
}
}

private static final class NewEntry implements Entry {
Expand Down Expand Up @@ -132,6 +139,11 @@ public boolean isOptional() {
public ModContainerImpl getModContainer() {
return mod;
}

@Override
public String getDefinition() {
return value;
}
}

private final Map<String, List<Entry>> entryMap = new HashMap<>();
Expand Down

0 comments on commit 12dd25f

Please sign in to comment.