package com.atlassian.bitbucket.mesh.git.exception;

import com.atlassian.bitbucket.mesh.rpc.v1.RpcGitError;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcNonFastForwardMerge;

import javax.annotation.Nonnull;

import static io.grpc.Status.ABORTED;

public class NonFastForwardMergeException extends MergeException {

    public NonFastForwardMergeException() {
        super("The branch or revision being merged is not fast-forward from the merge target", ABORTED);
    }

    @Nonnull
    @Override
    public RpcGitError toError() {
        return RpcGitError.newBuilder()
                .setNonFastForwardMerge(RpcNonFastForwardMerge.newBuilder()
                        .setFromCommitId(fromCommitId))
                .build();
    }
}
