You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/01/26 15:30:56 UTC

svn commit: r1063732 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java

Author: simonetripodi
Date: Wed Jan 26 14:30:56 2011
New Revision: 1063732

URL: http://svn.apache.org/viewvc?rev=1063732&view=rev
Log:
first checkin of ErrorMessage class

Added:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java   (with props)

Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java?rev=1063732&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java Wed Jan 26 14:30:56 2011
@@ -0,0 +1,91 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3;
+
+/**
+ * An error message and the context in which it occurred. Messages are usually created internally by
+ * {@code Digester} and its extensions. Messages can be created explicitly in a module using
+ * {@link org.apache.commons.digester3.RulesBinder#addError(Throwable) addError()} statement:
+ * <pre>try {
+ *   bindRulesFromFile();
+ * } catch (IOException e) {
+ *   addError(e);
+ * }</pre>
+ */
+final class ErrorMessage {
+
+    /**
+     * The error message text.
+     */
+    private final String message;
+
+    /**
+     * The throwable that caused this message.
+     */
+    /* @Nullable */ private final Throwable cause;
+
+    /**
+     * Create a new {@link ErrorMessage} instance from the error message text.
+     *
+     * @param message The error message text
+     */
+    public ErrorMessage(String message) {
+        this(message, null);
+    }
+
+    /**
+     * Create a new {@link ErrorMessage} instance from the error message text
+     * and the related cause.
+     *
+     * @param message The error message text
+     * @param cause The throwable that caused this message
+     */
+    public ErrorMessage(String message, Throwable cause) {
+        this.message = message;
+        this.cause = cause;
+    }
+
+    /**
+     * Gets the error message text.
+     *
+     * @return The error message text
+     */
+    public String getMessage() {
+        return this.message;
+    }
+
+    /**
+     * Returns the throwable that caused this message, or {@code null} if this
+     * message was not caused by a throwable.
+     *
+     * @return The throwable that caused this message, or {@code null} if this
+     *         message was not caused by a throwable
+     */
+    public Throwable getCause() {
+        return this.cause;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return this.message;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ErrorMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain