Skip to content
Snippets Groups Projects
Commit 68c83fe1 authored by Jens Bendisposto's avatar Jens Bendisposto
Browse files

Improved the error message

parent 77e49dcf
No related branches found
No related tags found
No related merge requests found
package de.prob.ui.eventb; package de.prob.ui.eventb;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
...@@ -67,9 +70,15 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { ...@@ -67,9 +70,15 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler {
final IEventBRoot rootElement = getRootElement(); final IEventBRoot rootElement = getRootElement();
final IFile resource = extractResource(rootElement); final IFile resource = extractResource(rootElement);
if (!checkErrorMarkers(resource)) { List<String> errors = checkErrorMarkers(resource);
String message = "A model/context in your project contains Errors or Warnings. This can lead to unexpected behavior (e.g. missing variables) when animating."; if (!errors.isEmpty()) {
Logger.notifyUserWithoutBugreport(message); String message = "A model/context in your project contains Errors or Warnings. This can lead to unexpected behavior (e.g. missing variables) when animating.\ns\nDetails:\n";
StringBuffer stringBuffer = new StringBuffer(message);
for (String string : errors) {
stringBuffer.append(string);
stringBuffer.append('\n');
}
Logger.notifyUserWithoutBugreport(stringBuffer.toString());
} }
; ;
...@@ -90,17 +99,24 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { ...@@ -90,17 +99,24 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler {
return null; return null;
} }
private boolean checkErrorMarkers(final IFile resource) { private List<String> checkErrorMarkers(final IFile resource) {
List<String> errors = new ArrayList<String>();
IProject project = resource.getProject(); IProject project = resource.getProject();
try { try {
IMarker[] markers = project.findMarkers( IMarker[] markers = project.findMarkers(
"org.eclipse.core.resources.problemmarker", true, "org.eclipse.core.resources.problemmarker", true,
IResource.DEPTH_INFINITE); IResource.DEPTH_INFINITE);
return markers.length == 0; for (IMarker iMarker : markers) {
} catch (CoreException e1) { errors.add(iMarker.getResource().getName()
+ ": "
+ iMarker
.getAttribute(IMarker.MESSAGE, "unknown Error"));
}
} catch (CoreException e1) {
} }
return false;
return errors;
} }
private IEventBRoot getRootElement() { private IEventBRoot getRootElement() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment