diff --git a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java index 5349e516..512752ef 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java +++ b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java @@ -635,7 +635,7 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike { * @return The proxy. */ public final T getProxy(@NotNull final Class proxyClass) { - Validate.notNull(proxyFactory, "Plugin does not support proxy!"); + Validate.notNull(proxyFactory, "Plugin does not support proxies!"); return proxyFactory.getProxy(proxyClass); } diff --git a/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/ProxyError.java b/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/ProxyError.java index cec95c59..735717b0 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/ProxyError.java +++ b/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/ProxyError.java @@ -5,12 +5,26 @@ import org.jetbrains.annotations.NotNull; /** * Generic error with proxy loading. */ -public class ProxyError extends RuntimeException { +public class ProxyError extends Error { /** * Thrown if there is an error getting a proxy. * * @param message The message to send. + * @param cause The cause. */ + public ProxyError(@NotNull final String message, + @NotNull final Throwable cause) { + super(message, cause); + } + + /** + * Thrown if there is an error getting a proxy. + * + * @param message The message to send. + * @deprecated Proxy Errors should include a cause. + */ + @Deprecated + @SuppressWarnings("DeprecatedIsStillUsed") public ProxyError(@NotNull final String message) { super(message); } diff --git a/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/UnsupportedVersionException.java b/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/UnsupportedVersionException.java index 422333ff..073b9668 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/UnsupportedVersionException.java +++ b/eco-api/src/main/java/com/willfp/eco/core/proxy/exceptions/UnsupportedVersionException.java @@ -1,5 +1,6 @@ package com.willfp.eco.core.proxy.exceptions; +import com.willfp.eco.core.proxy.ProxyConstants; import org.jetbrains.annotations.NotNull; /** @@ -10,8 +11,17 @@ public class UnsupportedVersionException extends ProxyError { * Thrown if the server is running an unsupported NMS version. * * @param message The message to send. + * @deprecated Use the default constructor. */ + @Deprecated(since = "6.24.0") public UnsupportedVersionException(@NotNull final String message) { super(message); } + + /** + * Thrown if the server is running an unsupported NMS version. + */ + public UnsupportedVersionException() { + super("You're running an unsupported server version: " + ProxyConstants.NMS_VERSION); + } } diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/proxy/EcoProxyFactory.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/proxy/EcoProxyFactory.kt index 9bb65c0e..1b4c6764 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/proxy/EcoProxyFactory.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/proxy/EcoProxyFactory.kt @@ -34,21 +34,26 @@ class EcoProxyFactory( return proxy } } catch (e: Exception) { - throwError(e) + throw proxyErrorFrom(e) } - throwError(IllegalArgumentException()) - - throw RuntimeException("Something went wrong.") + throw proxyErrorFrom(IllegalArgumentException("Class doesn't seem to be a proxy.")) } - private fun throwError(e: Exception?) { - e?.printStackTrace() + private fun proxyErrorFrom(e: Exception): Throwable { + plugin.logger.severe("Fatal error with proxies! This plugin can't load.") if (!SUPPORTED_VERSIONS.contains(ProxyConstants.NMS_VERSION)) { - throw UnsupportedVersionException("You're running an unsupported server version: " + ProxyConstants.NMS_VERSION) + throw ProxyError( + "Could not initialize proxy.", + UnsupportedVersionException() + ) } else { - throw ProxyError("Error with proxies - here's a stacktrace. Only god can help you now.") + throw ProxyError( + "Could not initialize proxy. If you're seeing this error message" + + ", something has gone badly wrong. This almost definitely isn't user error, blame the developer.", + e + ) } }