Browse Source

Improved Error Reporting (it was broken probably since I missed commiting Bundle.properties long time ago): If no throwable is given, the callstack is guessed automatically and there is a flag for issues and user-faults (where the hub is opened instead of the issue tracker)

MeFisto94 6 years ago
parent
commit
39cfcb4379

+ 8 - 1
jme3-core/src/com/jme3/gde/core/errorreport/Bundle.properties

@@ -1,3 +1,10 @@
 CTL_RendererInfoAction=Check Graphics Capabilities
 CTL_RendererInfoAction=Check Graphics Capabilities
 ExceptionPanel.jButton1.text=Copy to clipboard
 ExceptionPanel.jButton1.text=Copy to clipboard
-ExceptionPanel.jButton2.text=OK
+ExceptionPanel.jButton2.text=Open Help in Browser
+ExceptionPanel.jTextPane1.text=If you can see this, something really bad happened. An Exception has occured in the SDK.\nBut no worries, if you report that error to us, we can have a look at it.\nIt is really simple, all you have to do is have a look at the Error Details and Copy them to the clipboard (using the provided button)\nThen you can click "Open Help in Browser", it will directly take you to either the github issues page for "real" bugs in the SDK or\nto the hub if it looks like a user error where you can ask for help.\nSometimes it's wise to include information from the Graphic Capabilities Tab as that's the features of your GPU,\nbut this is mostly useful to debug errors with the engine itself\nThanks for your help at making the SDK bugfree.
+ExceptionPanel.jScrollPane2.TabConstraints.tabTitle=Information
+# Actually the TabbedPane is just the surrounding container
+ExceptionPanel.jTabbedPane1.TabConstraints.tabTitle=You shouldn't see this
+ExceptionPanel.jTabbedPane1.AccessibleContext.accessibleName=You shouldn't see this
+ExceptionPanel.jPanelRenderInfo.TabConstraints.tabTitle=Graphic Capabilities
+ExceptionPanel.jPanelExReport.TabConstraints.tabTitle=Error Details

+ 3 - 6
jme3-core/src/com/jme3/gde/core/errorreport/ExceptionPanel.form

@@ -49,7 +49,7 @@
           </AuxValues>
           </AuxValues>
           <Constraints>
           <Constraints>
             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
-              <JTabbedPaneConstraints tabName="General">
+              <JTabbedPaneConstraints tabName="Information">
                 <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                 <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                   <ResourceString bundle="com/jme3/gde/core/errorreport/Bundle.properties" key="ExceptionPanel.jScrollPane2.TabConstraints.tabTitle" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
                   <ResourceString bundle="com/jme3/gde/core/errorreport/Bundle.properties" key="ExceptionPanel.jScrollPane2.TabConstraints.tabTitle" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
                 </Property>
                 </Property>
@@ -76,7 +76,7 @@
           </Properties>
           </Properties>
           <Constraints>
           <Constraints>
             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
-              <JTabbedPaneConstraints tabName="Exception Details">
+              <JTabbedPaneConstraints tabName="Error Details">
                 <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                 <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                   <ResourceString bundle="com/jme3/gde/core/errorreport/Bundle.properties" key="ExceptionPanel.jPanelExReport.TabConstraints.tabTitle" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
                   <ResourceString bundle="com/jme3/gde/core/errorreport/Bundle.properties" key="ExceptionPanel.jPanelExReport.TabConstraints.tabTitle" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
                 </Property>
                 </Property>
@@ -90,7 +90,7 @@
                   <Group type="102" alignment="0" attributes="0">
                   <Group type="102" alignment="0" attributes="0">
                       <EmptySpace max="-2" attributes="0"/>
                       <EmptySpace max="-2" attributes="0"/>
                       <Component id="jButton1" min="-2" max="-2" attributes="0"/>
                       <Component id="jButton1" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace pref="251" max="32767" attributes="0"/>
+                      <EmptySpace pref="230" max="32767" attributes="0"/>
                       <Component id="jButton2" min="-2" max="-2" attributes="0"/>
                       <Component id="jButton2" min="-2" max="-2" attributes="0"/>
                       <EmptySpace max="-2" attributes="0"/>
                       <EmptySpace max="-2" attributes="0"/>
                   </Group>
                   </Group>
@@ -125,9 +125,6 @@
           </Layout>
           </Layout>
           <SubComponents>
           <SubComponents>
             <Container class="javax.swing.JScrollPane" name="jScrollPane1">
             <Container class="javax.swing.JScrollPane" name="jScrollPane1">
-              <Properties>
-                <Property name="horizontalScrollBarPolicy" type="int" value="31"/>
-              </Properties>
               <AuxValues>
               <AuxValues>
                 <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
                 <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
               </AuxValues>
               </AuxValues>

+ 9 - 8
jme3-core/src/com/jme3/gde/core/errorreport/ExceptionPanel.java

@@ -49,6 +49,7 @@ import org.openide.util.Exceptions;
  */
  */
 public final class ExceptionPanel extends JPanel {
 public final class ExceptionPanel extends JPanel {
     
     
+    protected boolean wantIssue = true;
     /**
     /**
      * Creates new form ExceptionPanel.
      * Creates new form ExceptionPanel.
      * 
      * 
@@ -58,7 +59,8 @@ public final class ExceptionPanel extends JPanel {
         initComponents();
         initComponents();
     }
     }
 
 
-    public ExceptionPanel(String text) {
+    public ExceptionPanel(String text, boolean wantIssue) {
+        this.wantIssue = wantIssue;
         initComponents();
         initComponents();
         setText(text);
         setText(text);
     }
     }
@@ -102,8 +104,6 @@ public final class ExceptionPanel extends JPanel {
 
 
         jPanelExReport.setName("panelExceptionReport"); // NOI18N
         jPanelExReport.setName("panelExceptionReport"); // NOI18N
 
 
-        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-
         jTextArea1.setEditable(false);
         jTextArea1.setEditable(false);
         jTextArea1.setColumns(20);
         jTextArea1.setColumns(20);
         jTextArea1.setLineWrap(true);
         jTextArea1.setLineWrap(true);
@@ -133,7 +133,7 @@ public final class ExceptionPanel extends JPanel {
             .addGroup(jPanelExReportLayout.createSequentialGroup()
             .addGroup(jPanelExReportLayout.createSequentialGroup()
                 .addContainerGap()
                 .addContainerGap()
                 .addComponent(jButton1)
                 .addComponent(jButton1)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 251, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 230, Short.MAX_VALUE)
                 .addComponent(jButton2)
                 .addComponent(jButton2)
                 .addContainerGap())
                 .addContainerGap())
             .addGroup(jPanelExReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(jPanelExReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -215,18 +215,19 @@ public final class ExceptionPanel extends JPanel {
     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
         try {
         try {
             Desktop desk = Desktop.getDesktop();
             Desktop desk = Desktop.getDesktop();
+            String uri = wantIssue ? ExceptionUtils.ISSUE_TRACKER_URL : ExceptionUtils.FORUMS_URL;            
             
             
             if (desk.isSupported(Desktop.Action.BROWSE)) {
             if (desk.isSupported(Desktop.Action.BROWSE)) {
-                Desktop.getDesktop().browse(new URI(ExceptionUtils.ISSUE_TRACKER_URL));
+                Desktop.getDesktop().browse(new URI(uri));
             } else {
             } else {
                 // Linux does not seem to be supported very well with Desktop.
                 // Linux does not seem to be supported very well with Desktop.
                 String os = System.getProperty("os.name");
                 String os = System.getProperty("os.name");
                 if (os.startsWith("Windows")) {
                 if (os.startsWith("Windows")) {
-                    Runtime.getRuntime().exec(new String[] { "explorer", ExceptionUtils.ISSUE_TRACKER_URL});
+                    Runtime.getRuntime().exec(new String[] { "explorer", uri});
                 } else if (os.startsWith("Mac OS")) {
                 } else if (os.startsWith("Mac OS")) {
-                    Runtime.getRuntime().exec(new String[] { "open", ExceptionUtils.ISSUE_TRACKER_URL});
+                    Runtime.getRuntime().exec(new String[] { "open", uri});
                 } else if (os.startsWith("Linux"))  {
                 } else if (os.startsWith("Linux"))  {
-                    Runtime.getRuntime().exec(new String[] { "xdg-open", ExceptionUtils.ISSUE_TRACKER_URL});
+                    Runtime.getRuntime().exec(new String[] { "xdg-open", uri});
                 }
                 }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {

+ 28 - 5
jme3-core/src/com/jme3/gde/core/errorreport/ExceptionUtils.java

@@ -47,17 +47,32 @@ import org.openide.DialogDisplayer;
 public class ExceptionUtils {
 public class ExceptionUtils {
     protected static String newLine = System.lineSeparator();//getProperty("line.separator");
     protected static String newLine = System.lineSeparator();//getProperty("line.separator");
     public static final String ISSUE_TRACKER_URL = "https://github.com/jMonkeyEngine/sdk/issues";
     public static final String ISSUE_TRACKER_URL = "https://github.com/jMonkeyEngine/sdk/issues";
+    public static final String FORUMS_URL = "https://hub.jmonkeyengine.org";
     
     
-    public static void caughtException(Throwable t, String comment) {
+    /**
+     * Notify the user about an Exception and tell him to visit either the SDK
+     * Issue Github Page or the Forums.
+     * 
+     * @param t The Exception that happened
+     * @param comment A Comment explaining the Situation
+     * @param wantIssue Whether we want to be informed using an issue or rather 
+     * only via a forum post.
+     */
+    public static void caughtException(Throwable t, String comment, boolean wantIssue) {
         StringBuilder sB = new StringBuilder();
         StringBuilder sB = new StringBuilder();
         sB.append("jMonkeyEngine SDK Exception Report");
         sB.append("jMonkeyEngine SDK Exception Report");
         sB.append(newLine);
         sB.append(newLine);
-        sB.append("Please submit me to the Issue Tracker");
+        if (wantIssue) {
+            sB.append("Please submit me to the Issue Tracker");
+        } else {
+            sB.append("If you need troubleshooting help, visit our forums, but "
+            + "don't report this as a github issue");
+        }
         sB.append(newLine);
         sB.append(newLine);
         sB.append("Comment: ");
         sB.append("Comment: ");
         sB.append(comment);
         sB.append(comment);
         sB.append(newLine);
         sB.append(newLine);
-        sB.append(Throwables.getStackTraceAsString(t));
+        sB.append(t != null ? Throwables.getStackTraceAsString(t) : fakeCallstack());
         sB.append(newLine);
         sB.append(newLine);
         //sB.append("Versions: ");
         //sB.append("Versions: ");
         //sB.append(newLine);
         //sB.append(newLine);
@@ -71,13 +86,21 @@ public class ExceptionUtils {
         sB.append(JmeVersion.VERSION_FULL);
         sB.append(JmeVersion.VERSION_FULL);
         //sB.append(newLine);
         //sB.append(newLine);
         
         
-        ExceptionPanel ep = new ExceptionPanel(sB.toString());
+        ExceptionPanel ep = new ExceptionPanel(sB.toString(), wantIssue);
         DialogDescriptor d = new DialogDescriptor(ep, "Oops! An Exception has occured.", true, new Object[] { DialogDescriptor.OK_OPTION }, DialogDescriptor.DEFAULT_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
         DialogDescriptor d = new DialogDescriptor(ep, "Oops! An Exception has occured.", true, new Object[] { DialogDescriptor.OK_OPTION }, DialogDescriptor.DEFAULT_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
         DialogDisplayer.getDefault().notifyLater(d);
         DialogDisplayer.getDefault().notifyLater(d);
    }
    }
     
     
+    public static void caughtException(Throwable t, String comment) {
+        caughtException(t, comment, true);
+    }
+    
     public static void caughtException(Throwable t) {
     public static void caughtException(Throwable t) {
-        caughtException(t, "");
+        caughtException(t, "", true);
+    }
+    
+    private static String fakeCallstack() {
+        return Throwables.getStackTraceAsString(new IllegalStateException("Fake-Callstack!"));
     }
     }
 }
 }