Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2007-01-22 07:45:14 +0000
committercbateman2007-01-22 07:45:14 +0000
commit3a64d631f733c6585a6d95210b10f048c16e2d2a (patch)
treec8c7c8858ead55450c0dc19a3f37d046e316393d /jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org
parenta05856765773955e6813a82898b2ed2c5ef1f047 (diff)
downloadwebtools.jsf-3a64d631f733c6585a6d95210b10f048c16e2d2a.tar.gz
webtools.jsf-3a64d631f733c6585a6d95210b10f048c16e2d2a.tar.xz
webtools.jsf-3a64d631f733c6585a6d95210b10f048c16e2d2a.zip
Improvement to avoid have the logger throw exceptions while logging other exceptions.
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org/eclipse/jst/jsf/common/ui/internal/logging/Logger.java45
1 files changed, 30 insertions, 15 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org/eclipse/jst/jsf/common/ui/internal/logging/Logger.java b/jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org/eclipse/jst/jsf/common/ui/internal/logging/Logger.java
index 4794c20f7..dc1a3e6d3 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org/eclipse/jst/jsf/common/ui/internal/logging/Logger.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common.ui/src/org/eclipse/jst/jsf/common/ui/internal/logging/Logger.java
@@ -41,8 +41,7 @@ public class Logger {
Object[] args = new Object[1];
args[0] = arg0;
- MessageFormat formatter = new MessageFormat(resourceBundle
- .getString(key));
+ MessageFormat formatter = new MessageFormat(getString(key));
String message = formatter.format(args);
IStatus status = new Status(IStatus.INFO, bundleId, IStatus.OK,
message, null);
@@ -56,7 +55,7 @@ public class Logger {
}
public void info(String key, Throwable e) {
- String message = resourceBundle.getString(key);
+ String message = getString(key);
IStatus status = new Status(IStatus.INFO, bundleId, IStatus.OK,
message, e);
log.log(status);
@@ -66,8 +65,7 @@ public class Logger {
Object[] args = new Object[1];
args[0] = arg0;
- MessageFormat formatter = new MessageFormat(resourceBundle
- .getString(key));
+ MessageFormat formatter = new MessageFormat(getString(key));
String message = formatter.format(args);
IStatus status = new Status(IStatus.INFO, bundleId, IStatus.OK,
message, null);
@@ -79,8 +77,7 @@ public class Logger {
args[0] = arg0;
args[1] = arg1;
- MessageFormat formatter = new MessageFormat(resourceBundle
- .getString(key));
+ MessageFormat formatter = new MessageFormat(getString(key));
String message = formatter.format(args);
IStatus status = new Status(IStatus.INFO, bundleId, IStatus.OK,
message, e);
@@ -88,7 +85,8 @@ public class Logger {
}
public void error(String key) {
- String message = resourceBundle.getString(key);
+
+ String message = getString(key);
IStatus status = new Status(IStatus.ERROR, bundleId, IStatus.OK,
message, null);
log.log(status);
@@ -100,7 +98,7 @@ public class Logger {
}
public void error(String key, Throwable e) {
- String message = resourceBundle.getString(key);
+ String message = getString(key);
IStatus status = new Status(IStatus.ERROR, bundleId, IStatus.OK,
message, e);
log.log(status);
@@ -110,8 +108,7 @@ public class Logger {
Object[] args = new Object[1];
args[0] = arg0;
- MessageFormat formatter = new MessageFormat(resourceBundle
- .getString(key));
+ MessageFormat formatter = new MessageFormat(getString(key));
String message = formatter.format(args);
IStatus status = new Status(IStatus.ERROR, bundleId, IStatus.OK,
message, null);
@@ -122,8 +119,7 @@ public class Logger {
Object[] args = new Object[1];
args[0] = arg;
- MessageFormat formatter = new MessageFormat(resourceBundle
- .getString(key));
+ MessageFormat formatter = new MessageFormat(getString(key));
String message = formatter.format(args);
IStatus status = new Status(IStatus.ERROR, bundleId, IStatus.OK,
message, e);
@@ -135,11 +131,30 @@ public class Logger {
args[0] = arg0;
args[1] = arg1;
- MessageFormat formatter = new MessageFormat(resourceBundle
- .getString(key));
+ MessageFormat formatter = new MessageFormat(getString(key));
String message = formatter.format(args);
IStatus status = new Status(IStatus.ERROR, bundleId, IStatus.OK,
message, e);
log.log(status);
}
+
+ /**
+ * @param key
+ * @return the resource for the key, or an error message if
+ * resourceBundle.getString(key) throws an Exception
+ */
+ private String getString(String key)
+ {
+ try
+ {
+ return resourceBundle.getString(key);
+ }
+ // suppress non-error exceptions so that the logging operation
+ // itself (usually called in response to an exception) does not
+ // throw a new exception
+ catch(Exception e)
+ {
+ return "!!missing resource: " + key + "!!";
+ }
+ }
}

Back to the top