Rocky_Mountain_Vending/.pnpm-store/v10/files/c1/0f89a3db3c42917276b11a43a9df442a42eff5b05a52781530cc52b37e36b5994fad215fc5ad00df4e5146e0da824a5051f7c22d0c037705348a69dc4ccd4c
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

39 lines
1.9 KiB
Text

import { CLOCK_SKEW_ERROR_CODES, NODEJS_NETWORK_ERROR_CODES, NODEJS_TIMEOUT_ERROR_CODES, THROTTLING_ERROR_CODES, TRANSIENT_ERROR_CODES, TRANSIENT_ERROR_STATUS_CODES, } from "./constants";
export const isRetryableByTrait = (error) => error?.$retryable !== undefined;
export const isClockSkewError = (error) => CLOCK_SKEW_ERROR_CODES.includes(error.name);
export const isClockSkewCorrectedError = (error) => error.$metadata?.clockSkewCorrected;
export const isBrowserNetworkError = (error) => {
const errorMessages = new Set([
"Failed to fetch",
"NetworkError when attempting to fetch resource",
"The Internet connection appears to be offline",
"Load failed",
"Network request failed",
]);
const isValid = error && error instanceof TypeError;
if (!isValid) {
return false;
}
return errorMessages.has(error.message);
};
export const isThrottlingError = (error) => error.$metadata?.httpStatusCode === 429 ||
THROTTLING_ERROR_CODES.includes(error.name) ||
error.$retryable?.throttling == true;
export const isTransientError = (error, depth = 0) => isRetryableByTrait(error) ||
isClockSkewCorrectedError(error) ||
TRANSIENT_ERROR_CODES.includes(error.name) ||
NODEJS_TIMEOUT_ERROR_CODES.includes(error?.code || "") ||
NODEJS_NETWORK_ERROR_CODES.includes(error?.code || "") ||
TRANSIENT_ERROR_STATUS_CODES.includes(error.$metadata?.httpStatusCode || 0) ||
isBrowserNetworkError(error) ||
(error.cause !== undefined && depth <= 10 && isTransientError(error.cause, depth + 1));
export const isServerError = (error) => {
if (error.$metadata?.httpStatusCode !== undefined) {
const statusCode = error.$metadata.httpStatusCode;
if (500 <= statusCode && statusCode <= 599 && !isTransientError(error)) {
return true;
}
return false;
}
return false;
};