Is there any way to get the error code and error message directly from Dataproc API

194 Views Asked by At

We are currently creating Dataproc clusters using below sample code,

from google.cloud import dataproc_v1

def sample_create_cluster():
    # Create a client
    client = dataproc_v1.ClusterControllerClient()

    # Initialize request argument(s)
    cluster = dataproc_v1.Cluster()
    cluster.project_id = "project_id_value"
    cluster.cluster_name = "cluster_name_value"

    request = dataproc_v1.CreateClusterRequest(
        project_id="project_id_value",
        region="region_value",
        cluster=cluster,
    )

    # Make the request
    operation = client.create_cluster(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

But incase any wrong input is sent through input payload, then I am getting errors in the html format like below, (in this case, I passed a wrong disk as pd-unknown just to show an error example)

<!doctype html>
<html lang=en>
<title>406 Not Acceptable</title>
<h1>Not Acceptable</h1>
<p>If provided, master boot disk type must be one of [pd-standard, pd-ssd, pd-balanced], but was &#39;pd-unknown&#39;</p>

This error looks a bit clumsy, is there any way we can capture the error code and error message in human readable format. Instead of html format.

I verified the library as well but I found nothing related to the error codes and status message. Any suggestion/message would help me.

0

There are 0 best solutions below