You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/12/28 23:11:10 UTC

svn commit: r1776355 - /jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java

Author: pmouawad
Date: Wed Dec 28 23:11:10 2016
New Revision: 1776355

URL: http://svn.apache.org/viewvc?rev=1776355&view=rev
Log:
Add methods to log exception

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java?rev=1776355&r1=1776354&r2=1776355&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java Wed Dec 28 23:11:10 2016
@@ -1090,22 +1090,50 @@ public class JMeterUtils implements Unit
      * @param errorMsg - the error message.
      */
     public static void reportErrorToUser(String errorMsg) {
-        reportErrorToUser(errorMsg, JMeterUtils.getResString("error_title")); // $NON-NLS-1$
+        reportErrorToUser(errorMsg, JMeterUtils.getResString("error_title"), null); // $NON-NLS-1$
     }
 
     /**
-     * Report an error through a dialog box.
+     * Report an error through a dialog box in GUI mode 
+     * or in logs and stdout in Non GUI mode
      *
      * @param errorMsg - the error message.
      * @param titleMsg - title string
      */
     public static void reportErrorToUser(String errorMsg, String titleMsg) {
+        reportErrorToUser(errorMsg, titleMsg, null);
+    }
+
+    /**
+     * Report an error through a dialog box.
+     * Title defaults to "error_title" resource string
+     * @param errorMsg - the error message.
+     * @param exception {@link Exception}
+     */
+    public static void reportErrorToUser(String errorMsg, Exception exception) {
+        reportErrorToUser(errorMsg, JMeterUtils.getResString("error_title"), exception);
+    }
+
+    /**
+     * Report an error through a dialog box in GUI mode 
+     * or in logs and stdout in Non GUI mode
+     *
+     * @param errorMsg - the error message.
+     * @param titleMsg - title string
+     * @param exception Exception
+     */
+    public static void reportErrorToUser(String errorMsg, String titleMsg, Exception exception) {
         if (errorMsg == null) {
             errorMsg = "Unknown error - see log file";
             log.warn("Unknown error", new Throwable("errorMsg == null"));
         }
         GuiPackage instance = GuiPackage.getInstance();
         if (instance == null) {
+            if(exception != null) {
+                log.error(errorMsg, exception);
+            } else {
+                log.error(errorMsg);
+            }
             System.out.println(errorMsg);
             return; // Done
         }