Skip to content

[ENH] Add handling for ChromaQuotaExceededError #4569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions clients/js/packages/chromadb-core/src/ChromaFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ChromaError,
createErrorByType,
ChromaUniqueError,
ChromaQuotaExceededError,
} from "./Errors";
import { FetchAPI } from "./generated";

Expand Down Expand Up @@ -74,6 +75,14 @@ export const chromaFetch: FetchAPI = async (
);
case 409:
throw new ChromaUniqueError("The resource already exists");
case 422:
if (
respBody?.message &&
respBody?.message.startsWith("Quota exceeded")
) {
throw new ChromaQuotaExceededError(respBody?.message);
}
break;
case 500:
throw parseServerError(respBody?.error);
case 502:
Expand Down
7 changes: 7 additions & 0 deletions clients/js/packages/chromadb-core/src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export class ChromaUniqueError extends Error {
}
}

export class ChromaQuotaExceededError extends Error {
name = "ChromaQuotaExceededError";
constructor(message: string, public readonly cause?: unknown) {
super(message);
}
}

export function createErrorByType(type: string, message: string) {
switch (type) {
case "InvalidCollection":
Expand Down
Loading