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
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
messagestringThe 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
messagestringThe error message that explains the reason for the exception.
innerExceptionExceptionThe 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
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
ErrorStatus
Gets the status of the error represented as a string.
[JsonPropertyName("status")]
public string ErrorStatus { get; }
Property Value
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.