package jetbrains.mps.ide.migration.wizard;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.errors.item.IssueKindReportItem;
import com.intellij.openapi.progress.ProgressIndicator;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.messages.IMessageHandler;
import jetbrains.mps.messages.Message;
import jetbrains.mps.messages.MessageKind;
import com.intellij.openapi.progress.EmptyProgressIndicator;

@GeneratedClass(node = "a5b1c28d-abeb-49a6-a58c-559039616d64/r:49062720-8530-4489-916a-fdd3a02a7b82(jetbrains.mps.migration.component/jetbrains.mps.ide.migration.wizard)/2620437876315875804", model = "a5b1c28d-abeb-49a6-a58c-559039616d64/r:49062720-8530-4489-916a-fdd3a02a7b82(jetbrains.mps.migration.component/jetbrains.mps.ide.migration.wizard)")
public abstract class MigrationError extends Exception {
  public MigrationError() {
  }

  public abstract String getShortMessage();

  public abstract String getMessage();

  /**
   * 
   * @return if migrations can start despite of errors
   */
  public abstract boolean canIgnore();

  /**
   * 
   * @return problems to show in model checker tool
   */
  public abstract Iterable<IssueKindReportItem> getProblems(ProgressIndicator progressIndicator);

  public void logProblems(@NotNull IMessageHandler handler) {
    handler.handle(Message.createMessage(MessageKind.ERROR, this.toString(), "Listing all the problems of " + this));
    for (IssueKindReportItem p : getProblems(new EmptyProgressIndicator())) {
      String problemMsg = p.getMessage() + " (reason object: " + IssueKindReportItem.PATH_OBJECT.get(p) + ")";
      handler.handle(Message.createMessage(MessageKind.ERROR, this.toString(), "- " + problemMsg));
    }
  }
}
