Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 37x 17x 20x 3x 17x 17x | import { ResourceLimitError } from '../errors/ResourceLimitError.ts';
import type {
ResourceLimitType,
ResourceLimitErrorData,
} from '../errors/ResourceLimitError.ts';
/**
* Check if an error is a ResourceLimitError, optionally with a specific limit type.
*
* @param error - The error to check.
* @param limitType - Optional limit type to match against.
* @returns True if the error is a ResourceLimitError (with matching limitType if specified).
*/
export function isResourceLimitError(
error: unknown,
limitType?: ResourceLimitType,
): error is ResourceLimitError {
if (!(error instanceof ResourceLimitError)) {
return false;
}
if (limitType === undefined) {
return true;
}
const data = error.data as ResourceLimitErrorData | undefined;
return data?.limitType === limitType;
}
|