Skip to content

Commit

Permalink
Add missing check for parser exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Feb 4, 2024
1 parent bcac5a7 commit bf85d69
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.incendo.cloud.exception.NoSuchCommandException;
import org.incendo.cloud.exception.handling.ExceptionContext;
import org.incendo.cloud.exception.handling.ExceptionHandler;
import org.incendo.cloud.exception.parsing.ParserException;
import org.incendo.cloud.minecraft.modded.ModdedCommandContextKeys;
import org.incendo.cloud.minecraft.modded.caption.MinecraftVariable;
import org.incendo.cloud.util.TypeUtils;
Expand Down Expand Up @@ -142,6 +143,8 @@ M extends CommandManager<C> & BrigadierManagerHolder<C, S>> void registerDefault
final Component msg;
if (exceptionContext.exception().getCause() instanceof CommandSyntaxException cse) {
msg = ComponentUtils.fromMessage(cse.getRawMessage());
} else if (exceptionContext.exception().getCause() instanceof ParserException parserException) {
msg = parserException.formatCaption(captionFormatter);
} else {
msg = Component.literal(exceptionContext.exception().getCause().getMessage());
}
Expand Down

0 comments on commit bf85d69

Please sign in to comment.