#
API error handling
Every non-2xx response from the Local API is an error. All SDKs deserialize the response body into a structured ProblemResponse object and surface it through a typed exception so you can react programmatically.
#
ProblemResponse structure
The API always returns an RFC 9457 ProblemResponse body on errors.
Note
Always branch on errorCode, not on title or detail. The human-readable fields are intended for logging and debugging, and their exact wording may change between versions.
#
ErrorCode values
The errorCode field is a string enum. All possible values are listed below.
#
Exception types per SDK
#
Python — ApiException
Raised by every API call that returns a non-2xx status. Import it from kameleo.local_api_client.exceptions.
#
JavaScript / TypeScript — ResponseError
Thrown by every SDK method on a non-2xx response. Import it from @kameleo/local-api-client.
#
C# — ApiException
Thrown by every async API method on a non-2xx response. Located in Kameleo.LocalApiClient.Client.
#
Catching and handling errors
The following examples show the recommended pattern: catch the SDK exception, check errorCode for known conditions, and let unexpected errors propagate or be handled at a higher level.
from kameleo.local_api_client.exceptions import ApiException
from kameleo.local_api_client.models import ErrorCode
try:
client.profile.delete_profile(profile_id)
except ApiException as ex:
if ex.error_code == ErrorCode.PROFILE_NOT_FOUND:
# Ignore: already deleted
print(f"Already deleted: {ex}")
else:
print(f"Unexpected error: {ex}")
raise
import { ErrorCode, ResponseError } from "@kameleo/local-api-client";
try {
await client.profile.deleteProfile(profileId);
} catch (error) {
if (error instanceof ResponseError && error.errorCode === ErrorCode.ProfileNotFound) {
// Ignore: already deleted
console.error("Already deleted:", error);
} else {
console.error("Unexpected error:", error);
throw error;
}
}
using Kameleo.LocalApiClient.Client;
using Kameleo.LocalApiClient.Model;
try
{
await client.Profile.DeleteProfileAsync(profileId);
}
catch (ApiException ex) when (ex.ErrorCode == ErrorCode.ProfileNotFound)
{
// Ignore: already deleted
Console.WriteLine($"Already deleted: {ex}");
}
catch (Exception ex)
{
Console.WriteLine($"Unexpected error: {ex}");
throw;
}