continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r209732 - in /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum: buildcontroller/ core/action/
Date Fri, 08 Jul 2005 10:31:03 GMT
Author: trygvis
Date: Fri Jul  8 03:30:59 2005
New Revision: 209732

URL: http://svn.apache.org/viewcvs?rev=209732&view=rev
Log:
o Improving error handling a bit.

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=209732&r1=209731&r2=209732&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Fri Jul  8 03:30:59 2005
@@ -29,6 +29,8 @@
 import org.apache.maven.continuum.scm.CheckOutScmResult;
 import org.apache.maven.continuum.scm.ScmFile;
 import org.apache.maven.continuum.scm.UpdateScmResult;
+import org.apache.maven.continuum.scm.ContinuumScmException;
+import org.apache.maven.continuum.scm.ScmResult;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ContinuumUtils;
@@ -116,11 +118,11 @@
 
                     actionManager.lookup( "checkout-project" ).execute( actionContext );
 
-                    CheckOutScmResult checkOutScmResult = AbstractContinuumAction.getCheckoutResult(
actionContext );
+                    CheckOutScmResult checkOutScmResult = AbstractContinuumAction.getCheckoutResult(
actionContext, null );
 
-                    String checkoutErrorMessage = AbstractContinuumAction.getCheckoutErrorMessage(
actionContext );
+                    String checkoutErrorMessage = AbstractContinuumAction.getCheckoutErrorMessage(
actionContext, null );
 
-                    String checkoutErrorException = AbstractContinuumAction.getCheckoutErrorException(
actionContext );
+                    String checkoutErrorException = AbstractContinuumAction.getCheckoutErrorException(
actionContext, null );
 
                     // ----------------------------------------------------------------------
                     // Check to see if there was a error while checking out the project
@@ -135,7 +137,7 @@
 
                         updateScmResult.setProviderMessage( checkOutScmResult.getProviderMessage()
);
 
-                        updateScmResult.setSuccess( checkOutScmResult.isSuccess() );
+                        updateScmResult.setSuccess( false );
 
                         for ( Iterator it = checkOutScmResult.getCheckedOutFiles().iterator();
it.hasNext(); )
                         {
@@ -154,11 +156,13 @@
 
                         if ( !StringUtils.isEmpty( checkoutErrorMessage ) )
                         {
-                            error = checkoutErrorMessage + System.getProperty( "line.separator"
);
+                            error = "Error message:" + System.getProperty( "line.separator"
);
+                            error = checkoutErrorException;
                         }
 
                         if ( !StringUtils.isEmpty( checkoutErrorException ) )
                         {
+                            error += "Exception:" + System.getProperty( "line.separator"
);
                             error += checkoutErrorException;
                         }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=209732&r1=209731&r2=209732&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
Fri Jul  8 03:30:59 2005
@@ -181,19 +181,19 @@
         return new File( getString( context, KEY_WORKING_DIRECTORY ) );
     }
 
-    public static CheckOutScmResult getCheckoutResult( Map context )
+    public static CheckOutScmResult getCheckoutResult( Map context, Object defaultValue )
     {
-        return (CheckOutScmResult) getObject( context, KEY_CHECKOUT_SCM_RESULT );
+        return (CheckOutScmResult) getObject( context, KEY_CHECKOUT_SCM_RESULT, defaultValue
);
     }
 
-    public static String getCheckoutErrorMessage( Map context )
+    public static String getCheckoutErrorMessage( Map context, String defaultValue )
     {
-        return getString( context, KEY_CHECKOUT_ERROR_MESSAGE );
+        return getString( context, KEY_CHECKOUT_ERROR_MESSAGE, defaultValue );
     }
 
-    public static String getCheckoutErrorException( Map context )
+    public static String getCheckoutErrorException( Map context, String defaultValue )
     {
-        return getString( context, KEY_CHECKOUT_ERROR_EXCEPTION );
+        return getString( context, KEY_CHECKOUT_ERROR_EXCEPTION, defaultValue );
     }
 
     public static UpdateScmResult getUpdateScmResult( Map context )
@@ -212,7 +212,12 @@
 
     protected static String getString( Map context, String key )
     {
-        return (String) context.get( key );
+        return (String) getObject( context, key );
+    }
+
+    protected static String getString( Map context, String key, String defaultValue )
+    {
+        return (String) getObject( context, key, defaultValue );
     }
 
     public static boolean getBoolean( Map context, String key )
@@ -226,14 +231,6 @@
 
         if ( value == null )
         {
-//            System.err.println( "context" );
-//            for ( Iterator it = context.keySet().iterator(); it.hasNext(); )
-//            {
-//                String s = (String) it.next();
-//
-//                System.err.println( s );
-//            }
-
             throw new RuntimeException( "Missing value for key '" + key + "'." );
         }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java?rev=209732&r1=209731&r2=209732&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
Fri Jul  8 03:30:59 2005
@@ -22,10 +22,12 @@
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.scm.CheckOutScmResult;
 import org.apache.maven.continuum.scm.ContinuumScmException;
-import org.apache.maven.continuum.store.AbstractContinuumStore;
+import org.apache.maven.continuum.scm.ScmResult;
 import org.apache.maven.continuum.utils.ContinuumUtils;
 import org.apache.maven.scm.manager.NoSuchScmProviderException;
 
+import org.codehaus.plexus.util.StringUtils;
+
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -40,21 +42,29 @@
 
         File workingDirectory = getWorkingDirectory( context );
 
-        CheckOutScmResult result = null;
-
-        String errorMessage = null;
-
-        Throwable exception = null;
-
         // ----------------------------------------------------------------------
         // Check out the project
         // ----------------------------------------------------------------------
 
         try
         {
-            result = getScm().checkOut( project, workingDirectory );
+            CheckOutScmResult result = getScm().checkOut( project, workingDirectory );
+
+            context.put( KEY_CHECKOUT_SCM_RESULT, result );
         }
-        catch ( ContinuumScmException e )
+        catch ( Throwable e )
+        {
+            handleThrowable( e, context );
+        }
+    }
+
+    public static void handleThrowable( Throwable e, Map context )
+    {
+        String errorMessage;
+
+        Throwable exception;
+
+        if ( e instanceof ContinuumScmException )
         {
             // TODO: Dissect the scm exception to be able to give better feedback
             Throwable cause = e.getCause();
@@ -62,22 +72,38 @@
             if ( cause instanceof NoSuchScmProviderException )
             {
                 errorMessage = cause.getMessage();
+
+                exception = null;
             }
             else
             {
+                ContinuumScmException ex = (ContinuumScmException) e;
+
+                ScmResult result = ex.getResult();
+
+                if ( result != null )
+                {
+                    errorMessage = "";
+                    errorMessage += "Provider message: "  + StringUtils.clean( result.getProviderMessage()
) + System.getProperty( "line.separator" );
+                    errorMessage += "Command output: " + System.getProperty( "line.separator"
);
+                    errorMessage += "-------------------------------------------------------------------------------";
+                    errorMessage += StringUtils.clean( result.getCommandOutput() );
+                    errorMessage += "-------------------------------------------------------------------------------";
+                }
+                else
+                {
+                    errorMessage = "";
+                }
+
                 exception = e;
             }
         }
-        catch ( Throwable e )
+        else
         {
+            errorMessage = "Unknown exception, type: " + e.getClass().getName();
+
             exception = e;
         }
-
-        // ----------------------------------------------------------------------
-        // Store the result in the context
-        // ----------------------------------------------------------------------
-
-        context.put( KEY_CHECKOUT_SCM_RESULT, result );
 
         context.put( KEY_CHECKOUT_ERROR_MESSAGE, errorMessage );
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java?rev=209732&r1=209731&r2=209732&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
Fri Jul  8 03:30:59 2005
@@ -40,11 +40,11 @@
             //
             // ----------------------------------------------------------------------
 
-            CheckOutScmResult checkOutScmResult = (CheckOutScmResult) context.get( KEY_CHECKOUT_SCM_RESULT
);
+            CheckOutScmResult checkOutScmResult = AbstractContinuumAction.getCheckoutResult(
context, null );
 
-            String checkoutErrorMessage = (String) context.get( KEY_CHECKOUT_ERROR_MESSAGE
);
+            String checkoutErrorMessage = AbstractContinuumAction.getCheckoutErrorMessage(
context, null );
 
-            String checkoutErrorException = (String) context.get( KEY_CHECKOUT_ERROR_EXCEPTION
);
+            String checkoutErrorException = AbstractContinuumAction.getCheckoutErrorException(
context, null );
 
             // ----------------------------------------------------------------------
             //

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=209732&r1=209731&r2=209732&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Fri Jul  8 03:30:59 2005
@@ -47,6 +47,10 @@
 
             context.put( KEY_UPDATE_SCM_RESULT, updateScmResult );
         }
+        catch( Throwable e )
+        {
+            CheckoutProjectContinuumAction.handleThrowable( e, context );
+        }
         finally
         {
             getNotifier().checkoutComplete( project, updateScmResult );



Mime
View raw message