diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EMFResourceUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EMFResourceUtils.java index 42137950da7b4be90686c843f74f646b75c8368e..711b208fc1287c017d8716e47c570ba9804826ea 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EMFResourceUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EMFResourceUtils.java @@ -41,7 +41,7 @@ import org.fortiss.tooling.kernel.ToolingKernelActivator; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 56BD3983999FF36819DDEDE7854E36EF + * @ConQAT.Rating YELLOW Hash: DF29CCFD1A2C94454FC9F8BFBD65E9CD */ public final class EMFResourceUtils { /** @@ -82,8 +82,8 @@ public final class EMFResourceUtils { } /** - * Loads the root model element from the given {@link URI}. Logs errors to the console and - * returns <code>null</code>. + * Loads the root model element from the given {@link URI}. Returns {@code null} in case of + * errors, and logs errors to the console. * * @param uri * the resource {@link URI}. @@ -91,6 +91,21 @@ public final class EMFResourceUtils { */ public static Pair<EObject, Map<EObject, AnyType>> loadModelFromFileWithUnknownFeatures(URI uri) { + return loadModelFromFileWithUnknownFeatures(uri, true); + } + + /** + * Loads the root model element from the given {@link URI}. Returns {@code null} in case of + * errors, and optionally logs errors to the console. + * + * @param uri + * the resource {@link URI}. + * @param logError + * Whether to log errors. + * @return the root {@link EObject}. + */ + public static Pair<EObject, Map<EObject, AnyType>> loadModelFromFileWithUnknownFeatures( + URI uri, boolean logError) { try { ResourceSet rset = new ResourceSetImpl(); Resource r; @@ -106,8 +121,12 @@ public final class EMFResourceUtils { unknownFeatures); } } catch(IOException ex) { - error(ToolingKernelActivator.getDefault(), - "Failed to load model from " + uri.toString(), ex); + if(logError) { + error(ToolingKernelActivator.getDefault(), + "Failed to load model from " + uri.toString(), ex); + } + } catch(Throwable t) { + return null; } return null; }