Skip to content

Commit 85951ca

Browse files
committed
docs: error handling with withRetry
1 parent a59ae61 commit 85951ca

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ An instance created by `lyla.withRetry` may encounter three types of errors when
612612
1. A Lyla Error returned by the reject action, which will be thrown directly without being wrapped.
613613
2. A non-Lyla Error (e.g., `error1`) returned by the reject action, which will be wrapped into a `RETRY_REJECTED_BY_NON_LYLA_ERROR` type error and thrown (e.g., `error2`). `error1` can be accessed via `error2.error`.
614614
3. An exception thrown by `onResolved` or `onRejected`, or an exception thrown by the value function of the retry action, which will be wrapped into a `BROKEN_RETRY` type error and thrown.
615+
4. Retry may throw 2 unique errors, `RETRY_REJECTED_BY_NON_LYLA_ERROR` and `BROKEN_RETRY`, which won't be caught by any hook and won't be judged as `true` by `isLylaError`. If you need to judge these two errors, you need to use `isLylaErrorWithRetry`, which will judge all Lyla Errors.
615616

616617
## FAQ
617618

README.zh_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ const lyla = _lyla.withRetry({
597597
1. 通过 reject action 返回了一个 Lyla Error,这个错误会被直接抛出,不会被包装
598598
2. 通过 reject action 返回了一个非 Lyla Error(比如 `error1`),这个错误会被包装成一个 `RETRY_REJECTED_BY_NON_LYLA_ERROR` 类型的错误并抛出(比如 `error2`),`error1` 可以通过 `error2.error` 获取
599599
3. `onResolved``onRejected` 抛出了异常,或者 retry action 的 value 函数抛出了异常,这个错误会被包装成一个 `BROKEN_RETRY` 类型的错误并抛出
600+
4. 重试可能会抛出两种独特的 Error,`RETRY_REJECTED_BY_NON_LYLA_ERROR``BROKEN_RETRY`,这两种错误不会被任何 hook 捕获,也不会被 `isLylaError` 判定为 `true`。如果你需要判断这两种错误,你需要使用 `isLylaErrorWithRetry`,这个函数会判断所有的 Lyla Error。
600601

601602
## FAQ
602603

0 commit comments

Comments
 (0)