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"
  );
} 

.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.
Was this page helpful?