MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / isStatusCodeInRange

Function isStatusCodeInRange

packages/trigger-sdk/src/v3/retry.ts:495–526  ·  view source on GitHub ↗
(statusCode: number, statusRange: string)

Source from the content-addressed store, hash-verified

493 * Returns `true` if the status code falls within the range, and `false` otherwise.
494 */
495const isStatusCodeInRange = (statusCode: number, statusRange: string): boolean => {
496 if (statusRange === "all") {
497 return true;
498 }
499
500 if (statusRange.includes(",")) {
501 const statusCodes = statusRange.split(",").map((s) => s.trim());
502
503 return statusCodes.some((s) => isStatusCodeInRange(statusCode, s));
504 }
505
506 const [start, end] = statusRange.split("-");
507
508 if (end) {
509 return statusCode >= parseInt(start, 10) && statusCode <= parseInt(end, 10);
510 }
511
512 if (start.endsWith("xx")) {
513 const prefix = start.slice(0, -2);
514 const statusCodePrefix = Math.floor(statusCode / 100).toString();
515 return statusCodePrefix === prefix;
516 }
517
518 const statusCodeString = statusCode.toString();
519 const rangePrefix = start.slice(0, -1);
520
521 if (start.endsWith("x") && statusCodeString.startsWith(rangePrefix)) {
522 return true;
523 }
524
525 return statusCode === parseInt(start, 10);
526};
527
528const createAttributesFromHeaders = (headers: Headers): Attributes => {
529 const attributes: Attributes = {};

Callers 1

Calls 2

sliceMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…