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.RpcRepositoryReadOnly;
import io.grpc.Metadata;
import io.grpc.Status;

public class RepositoryReadOnlyException extends AbstractStatusException {

    public RepositoryReadOnlyException() {
        super("Repository is in read-only mode", Status.FAILED_PRECONDITION);
    }

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