I am developing a large plugin, planned for use in a single server with multiple developers. For multiple reasons I want to use a custom exception handler to "notify" developers of bugs rather than having them check the console all the time.
I have seen a number of threads suggesting this:
The replies point to solutions that don't work in my case:
- Surrounding each problematic code section with a try/catch: My plugin is too large to do this for every event handler.
- Just keeping them in the console as exceptions "are not meant to be ignored": I'm not ignoring them, I'm just doing something other than sending them to the console.
This could be added by creating a ThrowableHandler interface with a single method
void handle(Throwable thrown);
, making an instance of it in SimplePluginManager, and setting a default implementation which logs to the console, same as before. You would need to add a method
setThrowableHandler(ThrowableHandler handler) {
so that developers could set their own implementation. The instance of this would be used when catching exceptions from onEnable, onDisable, and from events.