diff --git a/api/src/main/java/net/md_5/bungee/Util.java b/api/src/main/java/net/md_5/bungee/Util.java index e565c836..1457d4c8 100644 --- a/api/src/main/java/net/md_5/bungee/Util.java +++ b/api/src/main/java/net/md_5/bungee/Util.java @@ -88,11 +88,24 @@ public class Util * @return a string representing information about the {@link Throwable} */ public static String exception(Throwable t) + { + return exception( t, true ); + } + + /** + * Constructs a pretty one line version of a {@link Throwable}. Useful for + * debugging. + * + * @param t the {@link Throwable} to format. + * @param includeLineNumbers whether to include line numbers + * @return a string representing information about the {@link Throwable} + */ + public static String exception(Throwable t, boolean includeLineNumbers) { // TODO: We should use clear manually written exceptions StackTraceElement[] trace = t.getStackTrace(); return t.getClass().getSimpleName() + " : " + t.getMessage() - + ( ( trace.length > 0 ) ? " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber() : "" ); + + ( ( includeLineNumbers && trace.length > 0 ) ? " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber() : "" ); } public static String csv(Iterable objects) diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index bf25658b..e481d6df 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -8,7 +8,6 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; -import io.netty.channel.ConnectTimeoutException; import io.netty.util.internal.PlatformDependent; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -373,13 +372,7 @@ public final class UserConnection implements ProxiedPlayer private String connectionFailMessage(Throwable cause) { - if ( cause instanceof ConnectTimeoutException ) - { - return bungee.getTranslation( "timeout" ); - } else - { - return cause.getClass().getName(); - } + return Util.exception( cause, false ); } @Override diff --git a/proxy/src/main/resources/messages.properties b/proxy/src/main/resources/messages.properties index 5890e8c9..e16cf0a8 100644 --- a/proxy/src/main/resources/messages.properties +++ b/proxy/src/main/resources/messages.properties @@ -5,9 +5,8 @@ already_connecting=\u00a7cAlready connecting to this server! command_list=\u00a7a[{0}] \u00a7e({1}): \u00a7r{2} connect_kick=\u00a7cKicked whilst connecting to {0}: {1} current_server=\u00a76You are currently connected to {0}. -fallback_kick=\u00a7cCould not connect to a default or fallback server, please try again later: {0} +fallback_kick=\u00a7cCould not connect to a default or fallback server. Incorrectly configured address/port/firewall? {0} fallback_lobby=\u00a7cCould not connect to target server, you have been moved to a fallback server. -timeout=Server not reachable (timeout). Offline? Incorrectly configured address/port/firewall? lost_connection=[Proxy] Lost connection to server. mojang_fail=Error occurred while contacting login servers, are they down? no_permission=\u00a7cYou do not have permission to execute this command!