PromiseLogic.allRejected()
Extended FeatureGet all failure reasons, always returns a failure reason array
The PromiseLogic.allRejected() method returns all failure reasons as an array, ignoring successful results. It returns a PromiseWithTimer instance which wraps native Promise and provides additional functionality.
Syntax
javascript PromiseLogic.allRejected(iterable)
Parameters
| Parameter | Type | Description |
|---|---|---|
| iterable | Iterable<T | PromiseLike<T>> | An iterable collection of Promise objects |
Return Value
Returns a PromiseWithTimer that resolves to an array of reasons from all failed Promises (may be empty).
PromiseWithTimer<unknown[]>Behavior
Success Condition
Waits for all Promises to complete, then returns a PromiseWithTimer that resolves to an array of reasons from all failed Promises.
Special Case
The allRejected method never fails, even if all Promises succeed it will return an empty array.
Examples
Basic Usage
Get all failed operation reasons
JAVASCRIPT
Loading...
Timeout Control
Add timeout control with maxTimer method
JAVASCRIPT
Loading...
Error Analysis Report
Generate detailed error analysis report
JAVASCRIPT
Loading...
Real Application
Fault-tolerant system monitoring with timeout
JAVASCRIPT
Loading...
Important Notes
- • allRejected always returns successful results, even if all Promises succeed it returns an empty array
- • Returns PromiseWithTimer which supports maxTimer() for timeout control
- • maxTimer can only detect timeout, cannot cancel Promise operation itself
- • Suitable for scenarios where you need to analyze failure reasons without caring about success scenarios
- • Can be used for error monitoring, system health checks, failure analysis, etc.
- • Returned array only contains reasons from failed Promises, no success information