Skip to content

Commit

Permalink
Some better logging in MixinService initialisation, for science
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumfrey committed Nov 15, 2019
1 parent 3d58719 commit eb7a548
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/org/spongepowered/asm/service/MixinService.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ private synchronized IMixinService getServiceInstance() {
private IMixinService initService() {
this.serviceLoader = ServiceLoader.<IMixinService>load(IMixinService.class, this.getClass().getClassLoader());
Iterator<IMixinService> iter = this.serviceLoader.iterator();
List<String> rejectedServices = new ArrayList<String>();
List<String> badServices = new ArrayList<String>();
int brokenServiceCount = 0;
while (iter.hasNext()) {
try {
IMixinService service = iter.next();
Expand All @@ -140,14 +141,22 @@ private IMixinService initService() {
if (service.isValid()) {
return service;
}
rejectedServices.add(service.getName());
} catch (ServiceConfigurationError serviceError) {
// serviceError.printStackTrace();
MixinService.logger.debug("MixinService [{}] is not valid", service.getName());
badServices.add(String.format("INVALID[%s]", service.getName()));
} catch (ServiceConfigurationError sce) {
// sce.printStackTrace();
brokenServiceCount++;
} catch (Throwable th) {
String faultingClassName = th.getStackTrace()[0].getClassName();
MixinService.logger.debug("MixinService [{}] failed initialisation: {}", faultingClassName, th.getMessage());
int pos = faultingClassName.lastIndexOf('.');
badServices.add(String.format("ERROR[%s]", pos < 0 ? faultingClassName : faultingClassName.substring(pos + 1)));
// th.printStackTrace();
}
}
throw new ServiceNotAvailableError("No mixin host service is available. Rejected services: " + Joiner.on(", ").join(rejectedServices));

String brokenServiceNote = brokenServiceCount == 0 ? "" : " and " + brokenServiceCount + " other invalid services.";
throw new ServiceNotAvailableError("No mixin host service is available. Services: " + Joiner.on(", ").join(badServices) + brokenServiceNote);
}

/**
Expand Down

0 comments on commit eb7a548

Please sign in to comment.