Skip to content

ApiException

Namespace: TypeSafe.AI.Sdk

public class ApiException : TypeSafeException, ISerializable

An unsuccessful HTTP response from the API. Mirrors JS APIError.

Inheritance: object → Exception → TypeSafeException

Implements: ISerializable

Derived: AuthenticationException, BadRequestException, InternalServerException, NotFoundException, PermissionDeniedException, RateLimitException, UnprocessableEntityException

View source

ApiException(HttpStatusCode, object?, HttpResponseHeaders, string?)

Section titled “ApiException(HttpStatusCode, object?, HttpResponseHeaders, string?)”
public ApiException(HttpStatusCode statusCode, object? body, HttpResponseHeaders headers, string? message = null)

Create an API error from a completed HTTP response.

Parameters

Name Type Description
statusCode HttpStatusCode
body object
headers HttpResponseHeaders
message string

View source

public object? Body { get; }

Parsed JSON, response text, or null for an empty body.

Value: object

View source

public HttpResponseHeaders Headers { get; }

HTTP response headers.

Value: HttpResponseHeaders

View source

public string? RequestId { get; }

Request ID from x-typesafe-request-id, or null when absent.

Value: string

View source

public int Status { get; }

Numeric HTTP status.

Value: int

View source

public HttpStatusCode StatusCode { get; }

HTTP response status code.

Value: HttpStatusCode

View source

FromResponse(HttpStatusCode, object?, HttpResponseHeaders)

Section titled “FromResponse(HttpStatusCode, object?, HttpResponseHeaders)”
public static ApiException FromResponse(HttpStatusCode statusCode, object? body, HttpResponseHeaders headers)

Create the error subclass for an HTTP status code.

Parameters

Name Type Description
statusCode HttpStatusCode
body object
headers HttpResponseHeaders

Returns: ApiException

View source

MIT · Copyright (c) Dario Kondratiuk. · not affiliated with TypeSafe beyond being a client of the public API