Turn a stack trace into a string?

后端 未结 4 807
日久生厌
日久生厌 2021-01-08 00:23

Is it possible to print a stack trace to a string in GWT? The usual methods of using the classes in java.io won\'t work I think, because the java.io package is not available

4条回答
  •  感动是毒
    2021-01-08 00:35

    I would not recommend trying to display error stack trace in a GUI label.

    1) They are not readable after GWT Obfuscation. They just look like bunch of tab aligned characters over new lines.

    2) They are not in I18N format.

    3) The correct way is the just show user a well formed error "Message" . exception.getMessage() will give you a single line of non-obf information which should provide the necessary UX interaction to user.

    4) If you are looking for well formed exception stacktrace helpful for debugging ( not for user ) you should use GWT's well documented logging feature with web mode exceptions -

    a) https://developers.google.com/web-toolkit/doc/latest/DevGuideLogging

    b) Also read on http://code.google.com/p/google-web-toolkit/wiki/WebModeExceptions

提交回复
热议问题