You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by df...@apache.org on 2005/02/16 16:15:01 UTC

svn commit: r154028 - jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java

Author: dflorey
Date: Wed Feb 16 07:15:00 2005
New Revision: 154028

URL: http://svn.apache.org/viewcvs?view=rev&rev=154028
Log:
Added Localized errors and exception + refactoring

Added:
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java

Added: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java?view=auto&rev=154028
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java Wed Feb 16 07:15:00 2005
@@ -0,0 +1,50 @@
+/*
+ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons-sandbox//i18n/src/java/org/apache/commons/i18n/LocalizedException.java,v 1.1 2004/10/04 13:41:09 dflorey Exp $
+ * $Revision: 1.1 $
+ * $Date: 2005-02-14 20:03:07 +0100 (Mo, 14 Feb 2005) $
+ *
+ * ====================================================================
+ *
+ * Copyright 2004 The Apache Software Foundation 
+ *
+ * Licensed 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.i18n;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+
+import org.apache.commons.i18n.bundles.ErrorBundle;
+
+public class LocalizedError extends Error {
+    private ErrorBundle errorMessage;
+
+    public LocalizedError(ErrorBundle errorMessage, Throwable throwable) {
+        super(errorMessage.getSummary(Locale.getDefault(), throwable.getMessage()), throwable);
+        this.errorMessage = errorMessage;
+    }
+
+    public LocalizedError(ErrorBundle errorMessage) {
+        super(errorMessage.getSummary(
+                Locale.getDefault(), 
+                        MessageFormat.format(
+                                MessageManager.INTERNAL_MESSAGES.getString(MessageManager.MESSAGE_ENTRY_NOT_FOUND),
+                                new String[] { errorMessage.getId(), ErrorBundle.SUMMARY }))); 
+        this.errorMessage = errorMessage;
+    }
+
+    public ErrorBundle getErrorMessage() {
+        return errorMessage;
+    }
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org