use of com.intellij.openapi.command.AbnormalCommandTerminationException in project intellij-community by JetBrains.
the class CommandProcessorImpl method finishCommand.
@Override
public void finishCommand(final Project project, final Object command, final Throwable throwable) {
if (myCurrentCommand != command)
return;
final boolean failed;
try {
if (throwable instanceof AbnormalCommandTerminationException) {
final AbnormalCommandTerminationException rollback = (AbnormalCommandTerminationException) throwable;
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(rollback);
}
failed = true;
} else if (throwable != null) {
failed = true;
if (throwable instanceof Error) {
throw (Error) throwable;
} else if (throwable instanceof RuntimeException)
throw (RuntimeException) throwable;
CommandLog.LOG.error(throwable);
} else {
failed = false;
}
} finally {
super.finishCommand(project, command, throwable);
}
if (failed) {
if (project != null) {
FileEditor editor = new FocusBasedCurrentEditorProvider().getCurrentEditor();
final UndoManager undoManager = UndoManager.getInstance(project);
if (undoManager.isUndoAvailable(editor)) {
undoManager.undo(editor);
}
}
Messages.showErrorDialog(project, "Cannot perform operation. Too complex, sorry.", "Failed to Perform Operation");
}
}
Aggregations