Table of Contents

Class ApiException

Namespace
GenerativeAI.Exceptions
Assembly
GenerativeAI.dll

Represents an exception that occurs during API interactions.

public class ApiException : Exception, ISerializable
Inheritance
ApiException
Implements
Inherited Members
Extension Methods

Remarks

This exception is thrown when an error is encountered while interacting with an API. It encapsulates details such as the error code, error message, and error status to provide more context about the failure.

Constructors

ApiException()

Initializes a new instance of the ApiException class.

public ApiException()

ApiException(int, string, string)

Represents an exception that occurs when a platform-specific API operation fails.

public ApiException(int errorCode, string errorMessage, string errorStatus)

Parameters

errorCode int
errorMessage string
errorStatus string

Remarks

This exception includes additional details such as the error code, error message, and error status associated with the API failure.

ApiException(string)

Initializes a new instance of the ApiException class with a specified error message.

public ApiException(string message)

Parameters

message string

The error message that explains the reason for the exception.

ApiException(string, Exception)

Initializes a new instance of the ApiException class with a specified error message and inner exception.

public ApiException(string message, Exception innerException)

Parameters

message string

The error message that explains the reason for the exception.

innerException Exception

The exception that is the cause of the current exception.

Properties

ErrorCode

Gets the error code associated with the exception.

[JsonPropertyName("code")]
public int ErrorCode { get; }

Property Value

int

Remarks

The error code provides a numerical representation of the specific error that occurred, aiding in identifying and categorizing the issue.

ErrorMessage

Gets the error message that describes the exception. This message provides detailed information about the error encountered during the API operation.

[JsonPropertyName("message")]
public string ErrorMessage { get; }

Property Value

string

ErrorStatus

Gets the status of the error represented as a string.

[JsonPropertyName("status")]
public string ErrorStatus { get; }

Property Value

string

Remarks

This property contains a textual representation of the status of the error. It is typically used to provide additional context or categorization of the error, such as "BadRequest", "Unauthorized", or similar status indicators.