Skip to content

Errors

All library-specific errors extend FlowError. FlowError is an abstract base class; concrete failures are represented by one class per error.

Import

typescript
import {
  CircuitBreakerOpenError,
  FallbackChainExhaustedError,
  SchedulerAlreadyRunningError,
} from '@haskou/flow';

Signature

typescript
abstract class FlowError extends Error

Error list

ErrorThrown byMeaning
SemaphoreReleasedErrorSemaphorePermit.release()A permit was released more than once.
QueueClearedErrorQueue.clear()Pending queue work was cleared before it started.
CircuitBreakerOpenErrorCircuitBreaker.execute(), CircuitBreaker.run()The breaker rejected execution because it is open or half-open concurrency is full.
FlowCancelledErrorDebouncer.cancel()Pending debounce work was cancelled.
FlowAbortedErrorAbortable.run(), Flow.abortable()Running work was aborted.
FlowTaskMissingErrorFlow.run()No task was configured before running the flow.
FallbackChainExhaustedErrorFallbackChain.run()No fallback attempt produced a value.
TimeoutErrorTimeout.run(), Flow.timeout()Work exceeded its configured timeout.
RacerExhaustedErrorRacer.run()No racer candidate produced a successful value.
SchedulerAlreadyRunningErrorScheduler.assertStopped()The scheduler is running when stopped state is required.
InvalidSemaphorePermitsErrorSemaphorePermits must be a positive integer.
InvalidQueueConcurrencyErrorQueueOptionsQueue concurrency must be a positive integer.
InvalidRateLimiterIntervalErrorRateLimiterOptionsRate limiter interval must be a positive integer.
InvalidSchedulerIntervalErrorSchedulerOptionsScheduler interval must be a positive integer.
InvalidDebouncerDelayErrorDebouncerDebounce delay must be a positive integer.
InvalidThrottlerIntervalErrorThrottlerThrottle interval must be a positive integer.
InvalidTimeoutDurationErrorTimeoutTimeout duration must be a positive integer.
InvalidRetryAttemptsErrorRetryOptionsRetry attempts must be a positive integer.
InvalidRetryDelayErrorRetryOptionsRetry delay must be a non-negative integer.
InvalidCircuitBreakerFailureThresholdErrorCircuitBreakerOptionsFailure threshold must be a positive integer.
InvalidCircuitBreakerRecoveryTimeoutErrorCircuitBreakerOptionsRecovery timeout must be a positive integer.
InvalidCircuitBreakerSuccessThresholdErrorCircuitBreakerOptionsSuccess threshold must be a positive integer.
InvalidCircuitBreakerHalfOpenMaxConcurrentErrorCircuitBreakerOptionsHalf-open max concurrency must be a positive integer.

Example

typescript
import { CircuitBreakerOpenError } from '@haskou/flow';

try {
  await circuitBreaker.run(() => callProvider());
} catch (error) {
  if (error instanceof CircuitBreakerOpenError) {
    // Dependency is currently protected by the breaker.
  }
}

Validation notes

Numeric configuration values are validated before they are stored. When a value is invalid, the public constructor throws the error class that belongs to that option, such as InvalidTimeoutDurationError or InvalidRetryAttemptsError.

Released under the MIT License.