enebo / Purugin

Ruby Minecraft Plugin support on top of bukkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make error backtraces more salient

enebo opened this issue · comments

In issue #56 we see a typical backtrace in Purugin as it stands today. Here is one I just generated:

rg.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:298) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:157) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:814) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
    at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
Caused by: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `display_name' for #<Java::OrgBukkitEventPlayer::PlayerJoinEvent:0x5a3eca5e>
    at RUBY.on_enable(/Users/enebo/work/games/minecraft/plugins/a.rb:7) ~[?:?]
    at org.jruby.RubyProc.call(org/jruby/RubyProc.java:271) ~[?:?]
    at RUBY.on_event((eval):4) ~[?:?]
[

You will see Java framework is generating a wrapped exception but the real exception we want is our RaiseException generated from the ruby runtime itself.

So the challenge is to overload the handler OR possibly subclass the PluginException itself to not show all the other crud of spigot/craftbukkit in getMessages (or whatever Java exception backtrace generating method is called).

Ack I see the path forward and it is a little ugly. We need to override JavaPluginLoader.createRegisteredListeners in RubyPluginLoader. In this method if we can see it is a Ruby-derived class (not sure best way on this) we will set it up to use our own EventExecutor which generates a custom EventException which only returns the ruby bits of the backtrace. So not all that horrible...