Skip to content

Commit

Permalink
Propagate injection info exceptions correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumfrey committed Oct 11, 2019
1 parent f703afb commit 9d684ba
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.Map.Entry;

Expand Down Expand Up @@ -58,6 +59,7 @@
import org.spongepowered.asm.mixin.refmap.IMixinContext;
import org.spongepowered.asm.mixin.struct.SpecialMethodInfo;
import org.spongepowered.asm.mixin.throwables.MixinError;
import org.spongepowered.asm.mixin.throwables.MixinException;
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
Expand Down Expand Up @@ -131,6 +133,13 @@ static class InjectorEntry {
InjectionInfo create(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) {
try {
return this.ctor.newInstance(mixin, method, annotation);
} catch (InvocationTargetException itex) {
Throwable cause = itex.getCause();
if (cause instanceof MixinException) {
throw (MixinException)cause;
}
Throwable ex = cause != null ? cause : itex;
throw new MixinError("Error initialising injector metaclass [" + this.type + "] for annotation " + annotation.desc, ex);
} catch (ReflectiveOperationException ex) {
throw new MixinError("Failed to instantiate injector metaclass [" + this.type + "] for annotation " + annotation.desc, ex);
}
Expand Down

0 comments on commit 9d684ba

Please sign in to comment.