StrongJoshua / libgdx-inGameConsole

A LibGdx library that allows a developer to add a console (similar to how it is featured in Source games) to their game.
https://www.strongjoshua.net/projects/games/libgdx-ingame-console
Apache License 2.0
132 stars 34 forks source link

Print Stack Trace #22

Closed nibuen closed 7 years ago

nibuen commented 7 years ago

Would be nice to print the stack trace instead of just the message like so:

  catch (ReflectionException e) {
                String msg = e.getMessage();
                if (msg == null || msg.length() <= 0 || msg.equals("")) {
                    msg = "Unknown Error";
                    e.printStackTrace();
                }

               if(showConsoleStackTrace) {                   
                  StringWriter sw = new StringWriter();
                  PrintWriter pw = new PrintWriter(sw);
                  e.getCause().getCause().printStackTrace(pw);
                     log(sw.toString(), LogLevel.ERROR);
               }  else {
                  log(msg, LogLevel.ERROR);
               }
                return;
            }
BenMcLean commented 7 years ago

This feature would probably have to be marked as GWT incompatible unless it's written very cleverly to use the libGDX emulation of reflection for GWT.

nibuen commented 7 years ago

@BenMcLean This code is already there as this in AbstractConsole:

  catch (ReflectionException e) {
                String msg = e.getMessage();
                if (msg == null || msg.length() <= 0 || msg.equals("")) {
                    msg = "Unknown Error";
                    e.printStackTrace();
                }
                log(msg, LogLevel.ERROR);
                return;
            }

Should probably be a flag or something for it, since more useful if doing debugging and not for user.

Edit: Updated code sample above.

StrongJoshua commented 7 years ago

I have implemented this, it should be live soon.

StrongJoshua commented 7 years ago

Released in 0.5.3