diff options
| author | slewis | 2005-01-13 08:50:20 +0000 |
|---|---|---|
| committer | slewis | 2005-01-13 08:50:20 +0000 |
| commit | 2d09e505bbddccc4eb833978f860e7b19cc178d3 (patch) | |
| tree | d08200f52d0f5fc56cceff34709daa8297144f40 | |
| parent | fa7024f4593e8b7536a13f658c0741bc99319b74 (diff) | |
| download | org.eclipse.ecf-2d09e505bbddccc4eb833978f860e7b19cc178d3.tar.gz org.eclipse.ecf-2d09e505bbddccc4eb833978f860e7b19cc178d3.tar.xz org.eclipse.ecf-2d09e505bbddccc4eb833978f860e7b19cc178d3.zip | |
Improvements to exception reporting
3 files changed, 184 insertions, 171 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java index ee1105084..950542260 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/SharedObjectContainerFactory.java @@ -178,8 +178,11 @@ public class SharedObjectContainerFactory { .getInstantiator(); clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cd.getClassLoader()); } catch (Exception e) { - throw new SharedObjectContainerInstantiationException( - "Exception getting ISharedObjectContainerInstantiatior", e); + SharedObjectContainerInstantiationException newexcept = new SharedObjectContainerInstantiationException( + "makeSharedObjectContainer exception with description: "+desc+": "+e.getClass().getName()+": "+e.getMessage()); + newexcept.setStackTrace(e.getStackTrace()); + dumpStack("Exception in makeSharedObjectContainer",newexcept); + throw newexcept; } if (instantiator == null) throw new SharedObjectContainerInstantiationException( diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/comm/ConnectionFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/comm/ConnectionFactory.java index 1f5e1821d..173cc3915 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/comm/ConnectionFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/comm/ConnectionFactory.java @@ -11,177 +11,181 @@ package org.eclipse.ecf.core.comm; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; + import org.eclipse.ecf.core.comm.provider.ISynchAsynchConnectionInstantiator; import org.eclipse.ecf.core.util.AbstractFactory; import org.eclipse.ecf.internal.core.Trace; public class ConnectionFactory { - private static Hashtable connectiontypes = new Hashtable(); - private static Trace debug = Trace.create("connectionfactory"); - - public final static ConnectionDescription addDescription( - ConnectionDescription scd) { - debug("addDescription(" + scd + ")"); - return addDescription0(scd); - } - - protected static ConnectionDescription addDescription0( - ConnectionDescription n) { - if (n == null) - return null; - return (ConnectionDescription) connectiontypes.put(n.getName(), n); - } - - public final static boolean containsDescription(ConnectionDescription scd) { - return containsDescription0(scd); - } - - protected static boolean containsDescription0(ConnectionDescription scd) { - if (scd == null) - return false; - return connectiontypes.containsKey(scd.getName()); - } - - private static void debug(String msg) { - if (Trace.ON && debug != null) { - debug.msg(msg); - } - } - - private static void dumpStack(String msg, Throwable e) { - if (Trace.ON && debug != null) { - debug.dumpStack(e, msg); - } - } - - public final static ConnectionDescription getDescription( - ConnectionDescription scd) { - return getDescription0(scd); - } - - protected static ConnectionDescription getDescription0( - ConnectionDescription scd) { - if (scd == null) - return null; - return (ConnectionDescription) connectiontypes.get(scd.getName()); - } - - protected static ConnectionDescription getDescription0(String name) { - if (name == null) - return null; - return (ConnectionDescription) connectiontypes.get(name); - } - - public final static ConnectionDescription getDescriptionByName(String name) { - return getDescription0(name); - } - - public static final List getDescriptions() { - return getDescriptions0(); - } - - protected static List getDescriptions0() { - return new ArrayList(connectiontypes.values()); - } - - public static ISynchAsynchConnection makeSynchAsynchConnection( - ISynchAsynchConnectionEventHandler handler, - ConnectionDescription desc, Object[] args) - throws ConnectionInstantiationException { - if (handler == null) - throw new ConnectionInstantiationException( - "handler cannot be null"); - return makeSynchAsynchConnection(handler, desc, null, args); - } - - public static ISynchAsynchConnection makeSynchAsynchConnection( - ISynchAsynchConnectionEventHandler handler, - ConnectionDescription desc, String[] argTypes, Object[] args) - throws ConnectionInstantiationException { - debug("makeSynchAsynchConnection(" + handler + "," + desc + "," - + Trace.convertStringAToString(argTypes) + "," - + Trace.convertObjectAToString(args) + ")"); - if (handler == null) - throw new ConnectionInstantiationException( - "ISynchAsynchConnectionEventHandler cannot be null"); - if (desc == null) - throw new ConnectionInstantiationException( - "ConnectionDescription cannot be null"); - ConnectionDescription cd = desc; - if (cd == null) - throw new ConnectionInstantiationException("ConnectionDescription " - + desc.getName() + " not found"); - ISynchAsynchConnectionInstantiator instantiator = null; - Class clazzes[] = null; - try { - instantiator = (ISynchAsynchConnectionInstantiator) cd - .getInstantiator(); - clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cd - .getClassLoader()); - if (instantiator == null) - throw new InstantiationException( - "Instantiator for ConnectionDescription " - + cd.getName() + " is null"); - } catch (Exception e) { - throw new ConnectionInstantiationException( - "Exception getting instantiator for '" + desc.getName() - + "'", e); - } - debug("makeSynchAsynchConnection:got instantiator:" + instantiator); - // Ask instantiator to actually create instance - return instantiator.makeInstance(desc,handler, clazzes, args); - } - - public static ISynchAsynchConnection makeSynchAsynchConnection( - ISynchAsynchConnectionEventHandler handler, String descriptionName) - throws ConnectionInstantiationException { - if (handler == null) - throw new ConnectionInstantiationException( - "ISynchAsynchConnectionEventHandler cannot be null"); - ConnectionDescription desc = getDescriptionByName(descriptionName); - if (desc == null) - throw new ConnectionInstantiationException( - "Connection type named '" + descriptionName + "' not found"); - return makeSynchAsynchConnection(handler, desc, null, null); - } - - public static ISynchAsynchConnection makeSynchAsynchConnection( - ISynchAsynchConnectionEventHandler handler, String descriptionName, - Object[] args) throws ConnectionInstantiationException { - if (handler == null) - throw new ConnectionInstantiationException( - "ISynchAsynchConnectionEventHandler cannot be null"); - ConnectionDescription desc = getDescriptionByName(descriptionName); - if (desc == null) - throw new ConnectionInstantiationException( - "Connection type named '" + descriptionName + "' not found"); - return makeSynchAsynchConnection(handler, desc, args); - } - - public static ISynchAsynchConnection makeSynchAsynchConnection( - ISynchAsynchConnectionEventHandler handler, String descriptionName, - String[] argTypes, Object[] args) - throws ConnectionInstantiationException { - if (handler == null) - throw new ConnectionInstantiationException( - "ISynchAsynchConnectionEventHandler cannot be null"); - ConnectionDescription desc = getDescriptionByName(descriptionName); - if (desc == null) - throw new ConnectionInstantiationException( - "Connection type named '" + descriptionName + "' not found"); - return makeSynchAsynchConnection(handler, desc, argTypes, args); - } - - public final static ConnectionDescription removeDescription( - ConnectionDescription scd) { - debug("removeDescription(" + scd + ")"); - return removeDescription0(scd); - } - - protected static ConnectionDescription removeDescription0( - ConnectionDescription n) { - if (n == null) - return null; - return (ConnectionDescription) connectiontypes.remove(n.getName()); - } + private static Hashtable connectiontypes = new Hashtable(); + + private static Trace debug = Trace.create("connectionfactory"); + + public final static ConnectionDescription addDescription( + ConnectionDescription scd) { + debug("addDescription(" + scd + ")"); + return addDescription0(scd); + } + + protected static ConnectionDescription addDescription0( + ConnectionDescription n) { + if (n == null) + return null; + return (ConnectionDescription) connectiontypes.put(n.getName(), n); + } + + public final static boolean containsDescription(ConnectionDescription scd) { + return containsDescription0(scd); + } + + protected static boolean containsDescription0(ConnectionDescription scd) { + if (scd == null) + return false; + return connectiontypes.containsKey(scd.getName()); + } + + private static void debug(String msg) { + if (Trace.ON && debug != null) { + debug.msg(msg); + } + } + + private static void dumpStack(String msg, Throwable e) { + if (Trace.ON && debug != null) { + debug.dumpStack(e, msg); + } + } + + public final static ConnectionDescription getDescription( + ConnectionDescription scd) { + return getDescription0(scd); + } + + protected static ConnectionDescription getDescription0( + ConnectionDescription scd) { + if (scd == null) + return null; + return (ConnectionDescription) connectiontypes.get(scd.getName()); + } + + protected static ConnectionDescription getDescription0(String name) { + if (name == null) + return null; + return (ConnectionDescription) connectiontypes.get(name); + } + + public final static ConnectionDescription getDescriptionByName(String name) { + return getDescription0(name); + } + + public static final List getDescriptions() { + return getDescriptions0(); + } + + protected static List getDescriptions0() { + return new ArrayList(connectiontypes.values()); + } + + public static ISynchAsynchConnection makeSynchAsynchConnection( + ISynchAsynchConnectionEventHandler handler, + ConnectionDescription desc, Object[] args) + throws ConnectionInstantiationException { + if (handler == null) + throw new ConnectionInstantiationException("handler cannot be null"); + return makeSynchAsynchConnection(handler, desc, null, args); + } + + public static ISynchAsynchConnection makeSynchAsynchConnection( + ISynchAsynchConnectionEventHandler handler, + ConnectionDescription desc, String[] argTypes, Object[] args) + throws ConnectionInstantiationException { + debug("makeSynchAsynchConnection(" + handler + "," + desc + "," + + Trace.convertStringAToString(argTypes) + "," + + Trace.convertObjectAToString(args) + ")"); + if (handler == null) + throw new ConnectionInstantiationException( + "ISynchAsynchConnectionEventHandler cannot be null"); + if (desc == null) + throw new ConnectionInstantiationException( + "ConnectionDescription cannot be null"); + ConnectionDescription cd = desc; + if (cd == null) + throw new ConnectionInstantiationException("ConnectionDescription " + + desc.getName() + " not found"); + ISynchAsynchConnectionInstantiator instantiator = null; + Class clazzes[] = null; + try { + instantiator = (ISynchAsynchConnectionInstantiator) cd + .getInstantiator(); + clazzes = AbstractFactory.getClassesForTypes(argTypes, args, cd + .getClassLoader()); + if (instantiator == null) + throw new InstantiationException( + "Instantiator for ConnectionDescription " + + cd.getName() + " is null"); + } catch (Exception e) { + ConnectionInstantiationException newexcept = new ConnectionInstantiationException( + "makeSynchAsynchConnection exception with description: " + + desc + ": " + e.getClass().getName() + ": " + + e.getMessage()); + newexcept.setStackTrace(e.getStackTrace()); + dumpStack("Exception in makeSynchAsynchConnection", newexcept); + throw newexcept; + } + // Ask instantiator to actually create instance + return instantiator.makeInstance(desc, handler, clazzes, args); + } + + public static ISynchAsynchConnection makeSynchAsynchConnection( + ISynchAsynchConnectionEventHandler handler, String descriptionName) + throws ConnectionInstantiationException { + if (handler == null) + throw new ConnectionInstantiationException( + "ISynchAsynchConnectionEventHandler cannot be null"); + ConnectionDescription desc = getDescriptionByName(descriptionName); + if (desc == null) + throw new ConnectionInstantiationException( + "Connection type named '" + descriptionName + "' not found"); + return makeSynchAsynchConnection(handler, desc, null, null); + } + + public static ISynchAsynchConnection makeSynchAsynchConnection( + ISynchAsynchConnectionEventHandler handler, String descriptionName, + Object[] args) throws ConnectionInstantiationException { + if (handler == null) + throw new ConnectionInstantiationException( + "ISynchAsynchConnectionEventHandler cannot be null"); + ConnectionDescription desc = getDescriptionByName(descriptionName); + if (desc == null) + throw new ConnectionInstantiationException( + "Connection type named '" + descriptionName + "' not found"); + return makeSynchAsynchConnection(handler, desc, args); + } + + public static ISynchAsynchConnection makeSynchAsynchConnection( + ISynchAsynchConnectionEventHandler handler, String descriptionName, + String[] argTypes, Object[] args) + throws ConnectionInstantiationException { + if (handler == null) + throw new ConnectionInstantiationException( + "ISynchAsynchConnectionEventHandler cannot be null"); + ConnectionDescription desc = getDescriptionByName(descriptionName); + if (desc == null) + throw new ConnectionInstantiationException( + "Connection type named '" + descriptionName + "' not found"); + return makeSynchAsynchConnection(handler, desc, argTypes, args); + } + + public final static ConnectionDescription removeDescription( + ConnectionDescription scd) { + debug("removeDescription(" + scd + ")"); + return removeDescription0(scd); + } + + protected static ConnectionDescription removeDescription0( + ConnectionDescription n) { + if (n == null) + return null; + return (ConnectionDescription) connectiontypes.remove(n.getName()); + } }
\ No newline at end of file diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java index 43cb45b01..55667f084 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/IDFactory.java @@ -174,7 +174,13 @@ public class IDFactory { protected static void logAndThrow(String s, Throwable t) throws IDInstantiationException { - IDInstantiationException e = new IDInstantiationException(s, t); + IDInstantiationException e = null; + if (t != null) { + e = new IDInstantiationException(s+": "+t.getClass().getName()+": "+t.getMessage()); + e.setStackTrace(t.getStackTrace()); + } else { + e = new IDInstantiationException(s); + } logException(s, t); throw e; } |
