package com.atlassian.bitbucket.scm.git.command.merge;

import com.atlassian.bitbucket.i18n.KeyedMessage;
import com.atlassian.bitbucket.scm.git.GitException;
import com.atlassian.bitbucket.scm.git.command.merge.conflict.GitMergeConflict;
import com.google.common.collect.ImmutableList;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;

public class GitMergeException extends GitException {

    private final List<GitMergeConflict> conflicts;

    public GitMergeException(@Nonnull KeyedMessage message) {
        super(message);

        conflicts = Collections.emptyList();
    }

    public GitMergeException(@Nonnull KeyedMessage message, @Nonnull List<GitMergeConflict> conflicts) {
        super(message);

        this.conflicts = ImmutableList.copyOf(conflicts);
    }

    /**
     * @param message the message for the exception
     * @param cause   an optional cause for this exception
     */
    public GitMergeException(@Nonnull KeyedMessage message, @Nullable Throwable cause) {
        super(message, cause);

        conflicts = Collections.emptyList();
    }

    @Nonnull
    public List<GitMergeConflict> getConflicts() {
        return conflicts;
    }
}
