* Check if an error is due to a locked issue/PR/discussion. * GitHub API returns 403 with specific messages for locked resources. * This helper is used to determine if an operation should be silently ignored. * * @param {unknown} error - The error value to check * @returns {boolean} True if err
(error)
| 52 | * @returns {boolean} True if error is due to locked resource, false otherwise |
| 53 | */ |
| 54 | function isLockedError(error) { |
| 55 | // Check if the error has a 403 status code |
| 56 | const is403Error = error && typeof error === "object" && "status" in error && error.status === 403; |
| 57 | if (!is403Error) { |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | // Check if the error message mentions "locked" |
| 62 | const errorMessage = getErrorMessage(error); |
| 63 | const hasLockedMessage = Boolean(errorMessage && (errorMessage.includes("locked") || errorMessage.includes("Lock conversation"))); |
| 64 | |
| 65 | // Only return true if it's BOTH a 403 status code AND mentions locked |
| 66 | return hasLockedMessage; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Check if an error is due to a GitHub API rate limit being exceeded. |
no test coverage detected