Provide more information in connect errors

This commit is contained in:
md_5 2022-02-06 08:39:23 +11:00
parent d2d157c1fe
commit eae9d45c8a
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
3 changed files with 16 additions and 11 deletions

View File

@ -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)

View File

@ -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

View File

@ -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!