package com.atlassian.bitbucket.mesh.management;

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

import javax.annotation.Nullable;

public class ConfigurationFailedException extends AbstractStatusException {

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

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