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

import com.atlassian.bitbucket.mesh.AbstractStatusException;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcError;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcErrorUtils;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcRepositoryRepairFailed;
import io.grpc.Metadata;
import io.grpc.Status;

import javax.annotation.Nullable;

public class RepositoryRepairFailedException extends AbstractStatusException {

    public RepositoryRepairFailedException(@Nullable String message) {
        super(message, Status.INTERNAL);
    }

    public RepositoryRepairFailedException(@Nullable String message, @Nullable Throwable cause) {
        super(message, cause, Status.INTERNAL);
    }

    public RepositoryRepairFailedException(@Nullable Throwable cause) {
        super(cause, Status.INTERNAL);
    }

    @Override
    protected Metadata getTrailers() {
        return RpcErrorUtils.toMetadata(RpcError.newBuilder()
                .setRepositoryRepairFailed(RpcRepositoryRepairFailed.getDefaultInstance())
                .build());
    }
}
