How can I get de printStackTrace in Codename One?

75 views
Skip to first unread message

Pepe Cerezo

unread,
Oct 29, 2014, 12:09:15 PM10/29/14
to codenameone...@googlegroups.com
Hello,

How can I get de printStackTrace in Codename One. I use Netbeans.

When I put this code, the method getStackTrace gives an error compilation.
Is there any workaround to send this information in an Email?

Thanks in advance.

Display.getInstance().addEdtErrorHandler(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
         evt.consume();
         StringBuilder sb = new StringBuilder();
         sb.append("Exception in Application Mobi version ").append(Display.getInstance().getProperty("AppVersion", "Unknown"));
         sb.append("<br>OS ").append(Display.getInstance().getPlatformName());
         sb.append("<br>Error ").append(evt.getSource());
         sb.append("<br>Current Form ").append(Display.getInstance().getCurrent().getName());
         sb.append("<br>").append((Throwable)evt.getSource());
         Throwable t = (Throwable) evt.getSource();

         StackTraceElement[] traza = t.getStackTrace();

         final Writer tmpTrazaWriter = new StringWriter();
         final PrintWriter tmpPrintWriter = new PrintWriter(tmpTrazaWriter);
         t.printStackTrace(tmpPrintWriter);

         sb.append("<br>").append(t.getMessage());
         Global.serverConex.SendMail("Error Application Mobi", sb.toString()
         , "", "", "na...@email.com", "");
         }
         });


Shai Almog

unread,
Oct 29, 2014, 9:32:35 PM10/29/14
to codenameone...@googlegroups.com
Hi,
in the simulator printStackTrace works also Log.e(Exception) works for Android/Simulator & the new iOS VM.
For more details check out the crash protection video in the How Do I section http://www.codenameone.com/how-do-i.html

Shai Almog

unread,
Oct 29, 2014, 9:33:29 PM10/29/14
to codenameone...@googlegroups.com

Pepe Cerezo

unread,
Oct 30, 2014, 2:07:06 AM10/30/14
to codenameone...@googlegroups.com
Hello Shai,

Thanks for your answer. It's true, that works with the Log class. But you can not choose the email destination. The error is sent to the email account in codename one.

Is there any way to choose the email?

Thanks again.

Shai Almog

unread,
Oct 30, 2014, 8:35:01 AM10/30/14
to codenameone...@googlegroups.com
Hi,
no. We explicitly block that to prevent abuse of pro accounts.

Pepe Cerezo

unread,
Oct 30, 2014, 8:42:47 AM10/30/14
to codenameone...@googlegroups.com
Ok Shai,

Thanks for your help.

Have a nice day.
Reply all
Reply to author
Forward
0 new messages