KitError instances with a BorrowError
code. Errors fall into two Borrow categories:
- Input errors (codes
1200-1299) signal that the request is invalid, stale, or references state that doesn’t exist. Fix the request and retry. - Service errors (codes
8200-8299) signal a backend or provider failure. Most are transient and safe to retry. A few are fatal, so check the table row before retrying.
Handling errors
The thrownKitError.name is prefixed with BORROW_ (for example,
BORROW_LOAN_NOT_FOUND for the LOAN_NOT_FOUND code in the input errors
table). Match on error.code, not on the raw name.
Use the isInputError and isRetryableError helpers to branch:
TypeScript
Input errors
Service errors
Other errors
Some Borrow failures surface with codes outside theBorrowError range:
Retry a failed operation
kit.borrow.borrow, kit.borrow.repay, kit.borrow.addCollateral,
kit.borrow.withdrawCollateralRepayIfNeeded, and kit.borrow.closeLoan run
through several phases before they confirm onchain, and
kit.borrow.retry(error) resumes a failed operation from where it stopped. When
the Circle-signed execution has not expired, retry submits it again instead of
requesting a new one. An operation that already confirmed is refused, so a retry
cannot accidentally open a second loan or pay a repayment twice.
TypeScript
SIGNED_BUNDLE_EXPIRED (1213) is marked retryable, but kit.borrow.retry
resubmits the same signed execution and fails again. Handle it by calling the
original operation with a new idempotencyKey instead.
Wait before you call kit.borrow.retry. Some retryable failures need time to
clear, such as a loan that is still opening (LOAN_OPENING_PENDING) or a pause
of loan writes (PAUSED), which can last minutes or longer. Wait longer after
each failed attempt.
kit.borrow.retry refuses errors marked FATAL. A fatal failure during
submission, such as an RPC_ENDPOINT_ERROR or a batch confirmation timeout, can
mean the wallet already broadcast the batch. Check whether the earlier
transaction landed before you start the operation again.
To deduplicate submissions across process boundaries, see
Use idempotency keys.