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

import com.atlassian.bitbucket.mesh.git.exception.AbstractGitException;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcGitError;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcWorkTreeWriteFailed;
import io.grpc.Status;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class WorkTreeWriteException extends AbstractGitException {

    public WorkTreeWriteException(@Nullable String message, @Nullable Status status, @Nullable Throwable cause) {
        super(message, cause, status);
    }

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

    public WorkTreeWriteException(Throwable cause) {
        super(cause, Status.INTERNAL);
    }

    @Nonnull
    @Override
    public RpcGitError toError() {
        return RpcGitError.newBuilder()
                .setWorkTreeWriteFailed(RpcWorkTreeWriteFailed.getDefaultInstance())
                .build();
    }
}
