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

Install exception handler for command stack showing errors to user

Issue-Ref: 4169
Issue-Url: af3#4169



Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent 48cc9d15
No related branches found
No related tags found
1 merge request!1554169: Install exception handler for command stack showing errors to user
Pipeline #31824 passed
Pipeline: maven-releng

#31825

    AutoUndoCommandStack.java fc326adf66c6cea2354884cdc240da5f2f82689a GREEN
    EMFTransactionalCommand.java ba4b5bead9768b6ce6c955b9238cd96cb722533c GREEN
    EclipseResourceStorageService.java 5e60ef7628ea2ad4113cfebde939341e1b1f6cf2 GREEN
    ModelContext.java 76eeaef7f56da5f0e288cf96792850be606b7757 GREEN
    ModelContext.java 484298fe527a4b83a6dceaef5dd459f874f8b737 YELLOW
    NonDirtyingEMFTransactionalCommand.java d288ebe35d22442c603496b0c917fb99a8febeea GREEN
    ......@@ -20,6 +20,7 @@ import static org.eclipse.core.resources.IResource.DEPTH_ZERO;
    import static org.eclipse.emf.common.util.URI.createPlatformResourceURI;
    import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.buildOptionsMap;
    import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
    import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
    import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
    import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateMissingIDs;
    ......@@ -55,6 +56,8 @@ import org.eclipse.emf.ecore.util.Diagnostician;
    import org.eclipse.emf.ecore.util.EContentAdapter;
    import org.eclipse.emf.ecore.xmi.XMIResource;
    import org.eclipse.emf.ecore.xml.type.AnyType;
    import org.eclipse.emf.transaction.ExceptionHandler;
    import org.eclipse.emf.transaction.RollbackException;
    import org.eclipse.emf.transaction.TransactionalEditingDomain;
    import org.fortiss.tooling.kernel.ToolingKernelActivator;
    import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
    ......@@ -123,6 +126,18 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
    transactionalCommandStack = new AutoUndoCommandStack(editingDomain);
    transactionalCommandStack.addCommandStackListener(this);
    transactionalCommandStack.setExceptionHandler(new ExceptionHandler() {
    @Override
    public void handleException(Exception e) {
    // Each original exception results into a RollbackException that undoes the changes
    // of the failed command
    if(!(e instanceof RollbackException)) {
    showError(e.getMessage());
    error(ToolingKernelActivator.getDefault(), e.getMessage(), e);
    }
    }
    });
    // Install adapter to maintain XMI IDs
    resource.eAdapters().add(new EContentAdapter() {
    ......
    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