geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r783100 - in /geronimo/server/trunk/framework/modules: geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
Date Tue, 09 Jun 2009 19:25:56 GMT
Author: dwoods
Date: Tue Jun  9 19:25:56 2009
New Revision: 783100

URL: http://svn.apache.org/viewvc?rev=783100&view=rev
Log:
GERONIMO-4533 Fix 'This is ridiculous' error messages for thrown IllegalArgumentExceptions.

Modified:
    geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java

Modified: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java?rev=783100&r1=783099&r2=783100&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
Tue Jun  9 19:25:56 2009
@@ -41,9 +41,14 @@
  */
 public class PrintHelper {
 
-    public static String reformat(String source, int indent, int endCol) {
+    public static String reformat(String source, int indent, int width) {
+        int endCol = width;
+        if (endCol == 0) {
+            endCol = DEFAULT_WIDTH;
+        }
         if(endCol-indent < 10) {
-            throw new IllegalArgumentException("This is ridiculous!");
+            throw new IllegalArgumentException("Need at least 10 spaces for " +
+                "printing, but indent=" + indent + " and endCol=" + endCol);
         }
         StringBuffer buf = new StringBuffer((int)(source.length()*1.1));
         String prefix = indent == 0 ? "" : buildIndent(indent);

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java?rev=783100&r1=783099&r2=783100&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
Tue Jun  9 19:25:56 2009
@@ -49,13 +49,18 @@
      *
      * @param source The unformatted String
      * @param indent The number of characters to indent on the left
-     * @param endCol The maximum width of the entire line in characters,
+     * @param width  The maximum width of the entire line in characters,
      *               including indent (indent 10 with endCol 70 results
      *               in 60 "usable" characters).
      */
-    public static String reformat(String source, int indent, int endCol) {
+    public static String reformat(String source, int indent, int width) {
+        int endCol = width;
+        if (endCol == 0) {
+            endCol = DEFAULT_WIDTH;
+        }
         if (endCol - indent < 10) {
-            throw new IllegalArgumentException("This is ridiculous!");
+            throw new IllegalArgumentException("Need at least 10 spaces for " +
+                "printing, but indent=" + indent + " and endCol=" + endCol);
         }
         StringBuffer buf = new StringBuffer((int) (source.length() * 1.1));
         String prefix = indent == 0 ? "" : buildIndent(indent);
@@ -95,7 +100,7 @@
         return buf.toString();
     }
 
-    private final static int DEFAULT_TERM_WIDTH = 256;
+    private final static int DEFAULT_WIDTH = 76;
 
     public static void println(String line, int indent, ConsoleReader consoleReader) throws
IOException {
         int endCol = consoleReader.getTermwidth();
@@ -104,11 +109,12 @@
         // some terminals will give a terminal width of zero (e.g. emacs shell). 
         // in that case, default to a reasonable term width value.
         if (endCol == 0) {
-            endCol = DEFAULT_TERM_WIDTH;
+            endCol = DEFAULT_WIDTH;
         }
 
         if (endCol - indent < 10) {
-            throw new IllegalArgumentException("This is ridiculous!");
+            throw new IllegalArgumentException("Need at least 10 spaces for " +
+                "printing, but indent=" + indent + " and endCol=" + endCol);
         }
         String prefix = indent == 0 ? "" : buildIndent(indent);
         int pos;



Mime
View raw message