incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r708099 - in /incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event: EventUtil.java impl/JobEventHandler.java
Date Mon, 27 Oct 2008 07:31:01 GMT
Author: cziegeler
Date: Mon Oct 27 00:31:00 2008
New Revision: 708099

URL: http://svn.apache.org/viewvc?rev=708099&view=rev
Log:
Improve error messages.

Modified:
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java?rev=708099&r1=708098&r2=708099&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
Mon Oct 27 00:31:00 2008
@@ -359,7 +359,7 @@
                     oos.close();
                     node.setProperty(binPropertyName, new ByteArrayInputStream(baos.toByteArray()));
                 } catch (IOException ioe) {
-                    throw new RepositoryException("Unable to serialize properties.", ioe);
+                    throw new RepositoryException("Unable to serialize properties " + properties,
ioe);
                 }
             }
         }
@@ -546,4 +546,31 @@
         }
         return false;
     }
+
+    /**
+     * Improved toString method for an Event.
+     * This method prints out the event topic and all of the properties.
+     */
+    public static String toString(final Event e) {
+        if ( e == null ) {
+            return "<null>";
+        }
+        final StringBuffer buffer =new StringBuffer(e.getClass().getName());
+        buffer.append(" [topic=");
+        buffer.append(e.getTopic());
+        buffer.append(", properties=");
+        final String[] names = e.getPropertyNames();
+        if ( names != null ) {
+            for(int i=0;i<names.length;i++) {
+                if ( i>0) {
+                    buffer.append(",");
+                }
+                buffer.append(names[i]);
+                buffer.append('=');
+                buffer.append(e.getProperty(names[i]));
+            }
+        }
+        buffer.append("]");
+        return buffer.toString();
+    }
 }

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=708099&r1=708098&r2=708099&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Mon Oct 27 00:31:00 2008
@@ -265,7 +265,7 @@
                         info.nodePath = eventNode.getPath();
                     } catch (RepositoryException re ) {
                         // something went wrong, so let's log it
-                        this.logger.error("Exception during writing new job '" + nodePath
+ "' to repository.", re);
+                        this.logger.error("Exception during writing new job '" + EventUtil.toString(event)
+ "' to repository at " + nodePath, re);
                     }
                 } else {
                     try {
@@ -302,7 +302,7 @@
                         }
                     } catch (RepositoryException re ) {
                         // something went wrong, so let's log it
-                        this.logger.error("Exception during writing new job '" + nodePath
+ "' to repository.", re);
+                        this.logger.error("Exception during writing new job '" + event +
"' to repository at " + nodePath, re);
                     }
                 }
                 // if we were able to write the event into the repository



Mime
View raw message