ampp
ampp4mo ago

rate limit error catching in convex helpers

I'm not sure the usefulness of this function
ts
export function isRateLimitError(
error: unknown,
): error is { data: RateLimitError } {
return (
error instanceof ConvexError &&
"kind" in error.data &&
error.data.kind === "RateLimited"
);
}
ts
export function isRateLimitError(
error: unknown,
): error is { data: RateLimitError } {
return (
error instanceof ConvexError &&
"kind" in error.data &&
error.data.kind === "RateLimited"
);
}
.catch((err) => { if (isRateLimitError(err)) { as it causes a typescript error "TypeError: cannot use 'in' operator to search for "kind" in " if non-rate limit error gets triggered.
0 Replies
No replies yetBe the first to reply to this messageJoin