libgdx-inGameConsole icon indicating copy to clipboard operation
libgdx-inGameConsole copied to clipboard

Commands now give useful error messages even without consoleTrace active

Open klianc09 opened this issue 6 years ago • 0 comments

When consoleTrace is set to false, exceptions in commands will lead to useless messages:

Exception occurred in method: failFunction

This is caused by the fact that com.badlogic.gdx.utils.reflect.invoke() wraps the TargetInvokationException with a ReflectionException with that predefined message, therefore the check for an empty message in AbstractConsole is never true in that case.

if (msg == null || msg.length() <= 0) {
  msg = "Unknown Error";
  e.printStackTrace();
}

With this change the example failFunction command in Box2DTest will print the much more helpful:

Exception occurred in method: failFunction
java.lang.RuntimeException: This function was designed to fail.

Only tested on desktop. If it causes issues with GWT, the import might need to be avoided, but so far untested.

klianc09 avatar Oct 27 '19 09:10 klianc09