Skip to content
Snippets Groups Projects
Commit a5ef5f63 authored by Simon Barner's avatar Simon Barner
Browse files

- Add loadModelFromFileWithUnknownFeatures(URI uri, boolean logError) that...

- Add loadModelFromFileWithUnknownFeatures(URI uri, boolean logError) that enables to not log errors to the console
- loadModelFromFileWithUnknownFeatures(URI uri) kept for compatibility
parent c87dc9a3
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment