from datadog_api_client.v1 import model_utils def process_data(data): if not isinstance(data, dict): raise model_utils.ApiTypeError("Expected dict, got {}".format(type(data))) # do something with the data try: process_data("not a dict") except model_utils.ApiTypeError as e: print(e) # Output: Expected dict, got
from datadog_api_client.v1 import model_utils class MyModel: def __init__(self, data): if not isinstance(data, dict): raise model_utils.ApiTypeError("Expected dict, got {}".format(type(data))) self.data = data try: MyModel("not a dict") except model_utils.ApiTypeError as e: print(e) # Output: Expected dict, gotIn this example, the `MyModel` class raises an `ApiTypeError` if the argument passed to its constructor is not a dictionary. When the code is run with a non-dictionary argument, the `ApiTypeError` is caught and the error message is printed. Based on the package name, `datadog_api_client`, it is likely that this library provides utility functions for working with the Datadog API.