@clayroach/effect 3.19.14-source-capture.8 → 3.19.14-source-trace.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SourceLocation/package.json +6 -0
- package/dist/cjs/Effect.js +2 -28
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/FiberRef.js +12 -1
- package/dist/cjs/FiberRef.js.map +1 -1
- package/dist/cjs/Layer.js +2 -24
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/RuntimeFlags.js +1 -29
- package/dist/cjs/RuntimeFlags.js.map +1 -1
- package/dist/cjs/SourceLocation.js +60 -0
- package/dist/cjs/SourceLocation.js.map +1 -0
- package/dist/cjs/Tracer.js +1 -15
- package/dist/cjs/Tracer.js.map +1 -1
- package/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/cjs/internal/core.js +17 -50
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +18 -30
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +16 -65
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/layer/circular.js +1 -5
- package/dist/cjs/internal/layer/circular.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -3
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/logger.js +25 -2
- package/dist/cjs/internal/logger.js.map +1 -1
- package/dist/cjs/internal/runtimeFlags.js +2 -11
- package/dist/cjs/internal/runtimeFlags.js.map +1 -1
- package/dist/cjs/internal/tracer.js +1 -114
- package/dist/cjs/internal/tracer.js.map +1 -1
- package/dist/dts/Config.d.ts +2 -2
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +8 -29
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/FiberRef.d.ts +12 -0
- package/dist/dts/FiberRef.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +0 -22
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/RuntimeFlags.d.ts +0 -28
- package/dist/dts/RuntimeFlags.d.ts.map +1 -1
- package/dist/dts/SourceLocation.d.ts +88 -0
- package/dist/dts/SourceLocation.d.ts.map +1 -0
- package/dist/dts/Tracer.d.ts +0 -15
- package/dist/dts/Tracer.d.ts.map +1 -1
- package/dist/dts/index.d.ts +6 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/layer.d.ts.map +1 -1
- package/dist/dts/internal/runtimeFlags.d.ts.map +1 -1
- package/dist/esm/Effect.js +0 -26
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/FiberRef.js +11 -0
- package/dist/esm/FiberRef.js.map +1 -1
- package/dist/esm/Layer.js +0 -22
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/RuntimeFlags.js +0 -28
- package/dist/esm/RuntimeFlags.js.map +1 -1
- package/dist/esm/SourceLocation.js +51 -0
- package/dist/esm/SourceLocation.js.map +1 -0
- package/dist/esm/Tracer.js +0 -14
- package/dist/esm/Tracer.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/dist/esm/internal/core.js +12 -45
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +18 -30
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +13 -60
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/layer/circular.js +0 -4
- package/dist/esm/internal/layer/circular.js.map +1 -1
- package/dist/esm/internal/layer.js +0 -2
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/logger.js +25 -2
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/runtimeFlags.js +1 -9
- package/dist/esm/internal/runtimeFlags.js.map +1 -1
- package/dist/esm/internal/tracer.js +0 -111
- package/dist/esm/internal/tracer.js.map +1 -1
- package/package.json +12 -1
- package/src/Arbitrary.ts +1101 -0
- package/src/Array.ts +3589 -0
- package/src/BigDecimal.ts +1349 -0
- package/src/BigInt.ts +643 -0
- package/src/Boolean.ts +287 -0
- package/src/Brand.ts +360 -0
- package/src/Cache.ts +281 -0
- package/src/Cause.ts +1555 -0
- package/src/Channel.ts +2355 -0
- package/src/ChildExecutorDecision.ts +146 -0
- package/src/Chunk.ts +1495 -0
- package/src/Clock.ts +111 -0
- package/src/Config.ts +542 -0
- package/src/ConfigError.ts +270 -0
- package/src/ConfigProvider.ts +333 -0
- package/src/ConfigProviderPathPatch.ts +100 -0
- package/src/Console.ts +226 -0
- package/src/Context.ts +585 -0
- package/src/Cron.ts +706 -0
- package/src/Data.ts +596 -0
- package/src/DateTime.ts +1686 -0
- package/src/DefaultServices.ts +34 -0
- package/src/Deferred.ts +301 -0
- package/src/Differ.ts +450 -0
- package/src/Duration.ts +1000 -0
- package/src/Effect.ts +14817 -0
- package/src/Effectable.ts +107 -0
- package/src/Either.ts +1040 -0
- package/src/Encoding.ts +195 -0
- package/src/Equal.ts +98 -0
- package/src/Equivalence.ts +235 -0
- package/src/ExecutionPlan.ts +308 -0
- package/src/ExecutionStrategy.ts +119 -0
- package/src/Exit.ts +467 -0
- package/src/FastCheck.ts +9 -0
- package/src/Fiber.ts +744 -0
- package/src/FiberHandle.ts +540 -0
- package/src/FiberId.ts +195 -0
- package/src/FiberMap.ts +656 -0
- package/src/FiberRef.ts +444 -0
- package/src/FiberRefs.ts +204 -0
- package/src/FiberRefsPatch.ts +105 -0
- package/src/FiberSet.ts +491 -0
- package/src/FiberStatus.ts +108 -0
- package/src/Function.ts +1222 -0
- package/src/GlobalValue.ts +53 -0
- package/src/Graph.ts +3732 -0
- package/src/GroupBy.ts +103 -0
- package/src/HKT.ts +45 -0
- package/src/Hash.ts +195 -0
- package/src/HashMap.ts +519 -0
- package/src/HashRing.ts +317 -0
- package/src/HashSet.ts +2346 -0
- package/src/Inspectable.ts +287 -0
- package/src/Iterable.ts +1119 -0
- package/src/JSONSchema.ts +1044 -0
- package/src/KeyedPool.ts +167 -0
- package/src/Layer.ts +1228 -0
- package/src/LayerMap.ts +436 -0
- package/src/List.ts +977 -0
- package/src/LogLevel.ts +285 -0
- package/src/LogSpan.ts +25 -0
- package/src/Logger.ts +702 -0
- package/src/Mailbox.ts +268 -0
- package/src/ManagedRuntime.ts +180 -0
- package/src/Match.ts +1477 -0
- package/src/MergeDecision.ts +95 -0
- package/src/MergeState.ts +172 -0
- package/src/MergeStrategy.ts +107 -0
- package/src/Metric.ts +780 -0
- package/src/MetricBoundaries.ts +69 -0
- package/src/MetricHook.ts +151 -0
- package/src/MetricKey.ts +224 -0
- package/src/MetricKeyType.ts +262 -0
- package/src/MetricLabel.ts +47 -0
- package/src/MetricPair.ts +71 -0
- package/src/MetricPolling.ts +148 -0
- package/src/MetricRegistry.ts +48 -0
- package/src/MetricState.ts +257 -0
- package/src/Micro.ts +4405 -0
- package/src/ModuleVersion.ts +18 -0
- package/src/MutableHashMap.ts +411 -0
- package/src/MutableHashSet.ts +706 -0
- package/src/MutableList.ts +297 -0
- package/src/MutableQueue.ts +227 -0
- package/src/MutableRef.ts +202 -0
- package/src/NonEmptyIterable.ts +32 -0
- package/src/Number.ts +1071 -0
- package/src/Option.ts +2170 -0
- package/src/Order.ts +373 -0
- package/src/Ordering.ts +111 -0
- package/src/ParseResult.ts +2031 -0
- package/src/PartitionedSemaphore.ts +200 -0
- package/src/Pipeable.ts +566 -0
- package/src/Pool.ts +204 -0
- package/src/Predicate.ts +1405 -0
- package/src/Pretty.ts +205 -0
- package/src/PrimaryKey.ts +23 -0
- package/src/PubSub.ts +182 -0
- package/src/Queue.ts +644 -0
- package/src/Random.ts +204 -0
- package/src/RateLimiter.ts +138 -0
- package/src/RcMap.ts +141 -0
- package/src/RcRef.ts +122 -0
- package/src/Readable.ts +93 -0
- package/src/Record.ts +1274 -0
- package/src/RedBlackTree.ts +421 -0
- package/src/Redacted.ts +144 -0
- package/src/Ref.ts +180 -0
- package/src/RegExp.ts +38 -0
- package/src/Reloadable.ts +127 -0
- package/src/Request.ts +347 -0
- package/src/RequestBlock.ts +118 -0
- package/src/RequestResolver.ts +366 -0
- package/src/Resource.ts +119 -0
- package/src/Runtime.ts +383 -0
- package/src/RuntimeFlags.ts +336 -0
- package/src/RuntimeFlagsPatch.ts +183 -0
- package/src/STM.ts +2045 -0
- package/src/Schedule.ts +2219 -0
- package/src/ScheduleDecision.ts +62 -0
- package/src/ScheduleInterval.ts +151 -0
- package/src/ScheduleIntervals.ts +122 -0
- package/src/Scheduler.ts +353 -0
- package/src/Schema.ts +10914 -0
- package/src/SchemaAST.ts +3043 -0
- package/src/Scope.ts +204 -0
- package/src/ScopedCache.ts +151 -0
- package/src/ScopedRef.ts +117 -0
- package/src/Secret.ts +88 -0
- package/src/SingleProducerAsyncInput.ts +67 -0
- package/src/Sink.ts +1461 -0
- package/src/SortedMap.ts +287 -0
- package/src/SortedSet.ts +390 -0
- package/src/SourceLocation.ts +108 -0
- package/src/Stream.ts +6468 -0
- package/src/StreamEmit.ts +136 -0
- package/src/StreamHaltStrategy.ts +123 -0
- package/src/Streamable.ts +45 -0
- package/src/String.ts +778 -0
- package/src/Struct.ts +243 -0
- package/src/Subscribable.ts +100 -0
- package/src/SubscriptionRef.ts +298 -0
- package/src/Supervisor.ts +240 -0
- package/src/Symbol.ts +29 -0
- package/src/SynchronizedRef.ts +270 -0
- package/src/TArray.ts +495 -0
- package/src/TDeferred.ts +100 -0
- package/src/TMap.ts +515 -0
- package/src/TPriorityQueue.ts +223 -0
- package/src/TPubSub.ts +200 -0
- package/src/TQueue.ts +432 -0
- package/src/TRandom.ts +129 -0
- package/src/TReentrantLock.ts +224 -0
- package/src/TRef.ts +178 -0
- package/src/TSemaphore.ts +129 -0
- package/src/TSet.ts +365 -0
- package/src/TSubscriptionRef.ts +192 -0
- package/src/Take.ts +258 -0
- package/src/TestAnnotation.ts +158 -0
- package/src/TestAnnotationMap.ts +119 -0
- package/src/TestAnnotations.ts +117 -0
- package/src/TestClock.ts +556 -0
- package/src/TestConfig.ts +47 -0
- package/src/TestContext.ts +36 -0
- package/src/TestLive.ts +53 -0
- package/src/TestServices.ts +390 -0
- package/src/TestSized.ts +55 -0
- package/src/Tracer.ts +182 -0
- package/src/Trie.ts +840 -0
- package/src/Tuple.ts +305 -0
- package/src/Types.ts +353 -0
- package/src/Unify.ts +113 -0
- package/src/UpstreamPullRequest.ts +117 -0
- package/src/UpstreamPullStrategy.ts +121 -0
- package/src/Utils.ts +809 -0
- package/src/index.ts +1568 -0
- package/src/internal/array.ts +8 -0
- package/src/internal/blockedRequests.ts +520 -0
- package/src/internal/cache.ts +733 -0
- package/src/internal/cause.ts +1050 -0
- package/src/internal/channel/channelExecutor.ts +1200 -0
- package/src/internal/channel/channelState.ts +134 -0
- package/src/internal/channel/childExecutorDecision.ts +96 -0
- package/src/internal/channel/continuation.ts +200 -0
- package/src/internal/channel/mergeDecision.ts +113 -0
- package/src/internal/channel/mergeState.ts +120 -0
- package/src/internal/channel/mergeStrategy.ts +72 -0
- package/src/internal/channel/singleProducerAsyncInput.ts +259 -0
- package/src/internal/channel/subexecutor.ts +229 -0
- package/src/internal/channel/upstreamPullRequest.ts +84 -0
- package/src/internal/channel/upstreamPullStrategy.ts +87 -0
- package/src/internal/channel.ts +2603 -0
- package/src/internal/clock.ts +95 -0
- package/src/internal/completedRequestMap.ts +9 -0
- package/src/internal/concurrency.ts +54 -0
- package/src/internal/config.ts +716 -0
- package/src/internal/configError.ts +304 -0
- package/src/internal/configProvider/pathPatch.ts +97 -0
- package/src/internal/configProvider.ts +799 -0
- package/src/internal/console.ts +153 -0
- package/src/internal/context.ts +337 -0
- package/src/internal/core-effect.ts +2293 -0
- package/src/internal/core-stream.ts +998 -0
- package/src/internal/core.ts +3189 -0
- package/src/internal/data.ts +36 -0
- package/src/internal/dataSource.ts +327 -0
- package/src/internal/dateTime.ts +1277 -0
- package/src/internal/defaultServices/console.ts +100 -0
- package/src/internal/defaultServices.ts +163 -0
- package/src/internal/deferred.ts +46 -0
- package/src/internal/differ/chunkPatch.ts +211 -0
- package/src/internal/differ/contextPatch.ts +232 -0
- package/src/internal/differ/hashMapPatch.ts +220 -0
- package/src/internal/differ/hashSetPatch.ts +176 -0
- package/src/internal/differ/orPatch.ts +311 -0
- package/src/internal/differ/readonlyArrayPatch.ts +210 -0
- package/src/internal/differ.ts +200 -0
- package/src/internal/doNotation.ts +80 -0
- package/src/internal/effect/circular.ts +895 -0
- package/src/internal/effectable.ts +131 -0
- package/src/internal/either.ts +110 -0
- package/src/internal/encoding/base64.ts +286 -0
- package/src/internal/encoding/base64Url.ts +29 -0
- package/src/internal/encoding/common.ts +51 -0
- package/src/internal/encoding/hex.ts +315 -0
- package/src/internal/errors.ts +7 -0
- package/src/internal/executionPlan.ts +114 -0
- package/src/internal/executionStrategy.ts +74 -0
- package/src/internal/fiber.ts +388 -0
- package/src/internal/fiberId.ts +267 -0
- package/src/internal/fiberMessage.ts +82 -0
- package/src/internal/fiberRefs/patch.ts +144 -0
- package/src/internal/fiberRefs.ts +297 -0
- package/src/internal/fiberRuntime.ts +3842 -0
- package/src/internal/fiberScope.ts +71 -0
- package/src/internal/fiberStatus.ts +119 -0
- package/src/internal/groupBy.ts +530 -0
- package/src/internal/hashMap/array.ts +49 -0
- package/src/internal/hashMap/bitwise.ts +32 -0
- package/src/internal/hashMap/config.ts +14 -0
- package/src/internal/hashMap/keySet.ts +8 -0
- package/src/internal/hashMap/node.ts +391 -0
- package/src/internal/hashMap.ts +586 -0
- package/src/internal/hashSet.ts +323 -0
- package/src/internal/keyedPool.ts +244 -0
- package/src/internal/layer/circular.ts +214 -0
- package/src/internal/layer.ts +1483 -0
- package/src/internal/logSpan.ts +20 -0
- package/src/internal/logger-circular.ts +24 -0
- package/src/internal/logger.ts +522 -0
- package/src/internal/mailbox.ts +561 -0
- package/src/internal/managedRuntime/circular.ts +6 -0
- package/src/internal/managedRuntime.ts +134 -0
- package/src/internal/matcher.ts +652 -0
- package/src/internal/metric/boundaries.ts +75 -0
- package/src/internal/metric/hook.ts +483 -0
- package/src/internal/metric/key.ts +167 -0
- package/src/internal/metric/keyType.ts +238 -0
- package/src/internal/metric/label.ts +41 -0
- package/src/internal/metric/pair.ts +48 -0
- package/src/internal/metric/polling.ts +149 -0
- package/src/internal/metric/registry.ts +187 -0
- package/src/internal/metric/state.ts +290 -0
- package/src/internal/metric.ts +577 -0
- package/src/internal/opCodes/cause.ts +35 -0
- package/src/internal/opCodes/channel.ts +83 -0
- package/src/internal/opCodes/channelChildExecutorDecision.ts +17 -0
- package/src/internal/opCodes/channelMergeDecision.ts +11 -0
- package/src/internal/opCodes/channelMergeState.ts +17 -0
- package/src/internal/opCodes/channelMergeStrategy.ts +11 -0
- package/src/internal/opCodes/channelState.ts +23 -0
- package/src/internal/opCodes/channelUpstreamPullRequest.ts +11 -0
- package/src/internal/opCodes/channelUpstreamPullStrategy.ts +11 -0
- package/src/internal/opCodes/config.ts +65 -0
- package/src/internal/opCodes/configError.ts +35 -0
- package/src/internal/opCodes/continuation.ts +11 -0
- package/src/internal/opCodes/deferred.ts +11 -0
- package/src/internal/opCodes/effect.ts +89 -0
- package/src/internal/opCodes/layer.ts +59 -0
- package/src/internal/opCodes/streamHaltStrategy.ts +23 -0
- package/src/internal/option.ts +80 -0
- package/src/internal/pool.ts +432 -0
- package/src/internal/pubsub.ts +1762 -0
- package/src/internal/query.ts +204 -0
- package/src/internal/queue.ts +766 -0
- package/src/internal/random.ts +161 -0
- package/src/internal/rateLimiter.ts +93 -0
- package/src/internal/rcMap.ts +285 -0
- package/src/internal/rcRef.ts +192 -0
- package/src/internal/redBlackTree/iterator.ts +200 -0
- package/src/internal/redBlackTree/node.ts +68 -0
- package/src/internal/redBlackTree.ts +1245 -0
- package/src/internal/redacted.ts +73 -0
- package/src/internal/ref.ts +171 -0
- package/src/internal/reloadable.ts +140 -0
- package/src/internal/request.ts +177 -0
- package/src/internal/resource.ts +76 -0
- package/src/internal/ringBuffer.ts +68 -0
- package/src/internal/runtime.ts +558 -0
- package/src/internal/runtimeFlags.ts +178 -0
- package/src/internal/runtimeFlagsPatch.ts +103 -0
- package/src/internal/schedule/decision.ts +47 -0
- package/src/internal/schedule/interval.ts +101 -0
- package/src/internal/schedule/intervals.ts +180 -0
- package/src/internal/schedule.ts +2199 -0
- package/src/internal/schema/errors.ts +191 -0
- package/src/internal/schema/schemaId.ts +106 -0
- package/src/internal/schema/util.ts +50 -0
- package/src/internal/scopedCache.ts +644 -0
- package/src/internal/scopedRef.ts +118 -0
- package/src/internal/secret.ts +89 -0
- package/src/internal/singleShotGen.ts +35 -0
- package/src/internal/sink.ts +2120 -0
- package/src/internal/stack.ts +10 -0
- package/src/internal/stm/core.ts +817 -0
- package/src/internal/stm/entry.ts +59 -0
- package/src/internal/stm/journal.ts +123 -0
- package/src/internal/stm/opCodes/stm.ts +71 -0
- package/src/internal/stm/opCodes/stmState.ts +17 -0
- package/src/internal/stm/opCodes/strategy.ts +17 -0
- package/src/internal/stm/opCodes/tExit.ts +29 -0
- package/src/internal/stm/opCodes/tryCommit.ts +11 -0
- package/src/internal/stm/stm.ts +1453 -0
- package/src/internal/stm/stmState.ts +136 -0
- package/src/internal/stm/tArray.ts +550 -0
- package/src/internal/stm/tDeferred.ts +81 -0
- package/src/internal/stm/tExit.ts +190 -0
- package/src/internal/stm/tMap.ts +824 -0
- package/src/internal/stm/tPriorityQueue.ts +267 -0
- package/src/internal/stm/tPubSub.ts +551 -0
- package/src/internal/stm/tQueue.ts +393 -0
- package/src/internal/stm/tRandom.ts +140 -0
- package/src/internal/stm/tReentrantLock.ts +352 -0
- package/src/internal/stm/tRef.ts +195 -0
- package/src/internal/stm/tSemaphore.ts +113 -0
- package/src/internal/stm/tSet.ts +259 -0
- package/src/internal/stm/tSubscriptionRef.ts +286 -0
- package/src/internal/stm/tryCommit.ts +34 -0
- package/src/internal/stm/txnId.ts +14 -0
- package/src/internal/stm/versioned.ts +4 -0
- package/src/internal/stream/debounceState.ts +57 -0
- package/src/internal/stream/emit.ts +123 -0
- package/src/internal/stream/haltStrategy.ts +94 -0
- package/src/internal/stream/handoff.ts +187 -0
- package/src/internal/stream/handoffSignal.ts +59 -0
- package/src/internal/stream/pull.ts +34 -0
- package/src/internal/stream/sinkEndReason.ts +30 -0
- package/src/internal/stream/zipAllState.ts +88 -0
- package/src/internal/stream/zipChunksState.ts +56 -0
- package/src/internal/stream.ts +8801 -0
- package/src/internal/string-utils.ts +107 -0
- package/src/internal/subscriptionRef.ts +138 -0
- package/src/internal/supervisor/patch.ts +190 -0
- package/src/internal/supervisor.ts +303 -0
- package/src/internal/synchronizedRef.ts +114 -0
- package/src/internal/take.ts +199 -0
- package/src/internal/testing/sleep.ts +27 -0
- package/src/internal/testing/suspendedWarningData.ts +85 -0
- package/src/internal/testing/warningData.ts +94 -0
- package/src/internal/tracer.ts +150 -0
- package/src/internal/trie.ts +722 -0
- package/src/internal/version.ts +7 -0
package/src/Cause.ts
ADDED
|
@@ -0,0 +1,1555 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Effect<A, E, R>` type is polymorphic in values of type `E` and we can
|
|
3
|
+
* work with any error type that we want. However, there is a lot of information
|
|
4
|
+
* that is not inside an arbitrary `E` value. So as a result, an `Effect` needs
|
|
5
|
+
* somewhere to store things like unexpected errors or defects, stack and
|
|
6
|
+
* execution traces, causes of fiber interruptions, and so forth.
|
|
7
|
+
*
|
|
8
|
+
* Effect-TS is very strict about preserving the full information related to a
|
|
9
|
+
* failure. It captures all type of errors into the `Cause` data type. `Effect`
|
|
10
|
+
* uses the `Cause<E>` data type to store the full story of failure. So its
|
|
11
|
+
* error model is lossless. It doesn't throw information related to the failure
|
|
12
|
+
* result. So we can figure out exactly what happened during the operation of
|
|
13
|
+
* our effects.
|
|
14
|
+
*
|
|
15
|
+
* It is important to note that `Cause` is an underlying data type representing
|
|
16
|
+
* errors occuring within an `Effect` workflow. Thus, we don't usually deal with
|
|
17
|
+
* `Cause`s directly. Even though it is not a data type that we deal with very
|
|
18
|
+
* often, the `Cause` of a failing `Effect` workflow can be accessed at any
|
|
19
|
+
* time, which gives us total access to all parallel and sequential errors in
|
|
20
|
+
* occurring within our codebase.
|
|
21
|
+
*
|
|
22
|
+
* @since 2.0.0
|
|
23
|
+
*/
|
|
24
|
+
import type * as Channel from "./Channel.js"
|
|
25
|
+
import type * as Chunk from "./Chunk.js"
|
|
26
|
+
import type * as Effect from "./Effect.js"
|
|
27
|
+
import type * as Either from "./Either.js"
|
|
28
|
+
import type * as Equal from "./Equal.js"
|
|
29
|
+
import type * as FiberId from "./FiberId.js"
|
|
30
|
+
import type * as HashSet from "./HashSet.js"
|
|
31
|
+
import type { Inspectable } from "./Inspectable.js"
|
|
32
|
+
import * as internal from "./internal/cause.js"
|
|
33
|
+
import * as core from "./internal/core.js"
|
|
34
|
+
import type * as Option from "./Option.js"
|
|
35
|
+
import type { Pipeable } from "./Pipeable.js"
|
|
36
|
+
import type { Predicate, Refinement } from "./Predicate.js"
|
|
37
|
+
import type * as Sink from "./Sink.js"
|
|
38
|
+
import type * as Stream from "./Stream.js"
|
|
39
|
+
import type { Span } from "./Tracer.js"
|
|
40
|
+
import type { Covariant, NoInfer } from "./Types.js"
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A unique symbol identifying the `Cause` type.
|
|
44
|
+
*
|
|
45
|
+
* **Details**
|
|
46
|
+
*
|
|
47
|
+
* This provides a symbol that helps identify instances of the `Cause` data
|
|
48
|
+
* type. This can be used for advanced operations such as refining types or
|
|
49
|
+
* building internal utilities that check whether an unknown value is a `Cause`.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link isCause} Check if a value is a `Cause`
|
|
52
|
+
*
|
|
53
|
+
* @since 2.0.0
|
|
54
|
+
* @category Symbols
|
|
55
|
+
*/
|
|
56
|
+
export const CauseTypeId: unique symbol = internal.CauseTypeId
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @since 2.0.0
|
|
60
|
+
* @category Symbols
|
|
61
|
+
*/
|
|
62
|
+
export type CauseTypeId = typeof CauseTypeId
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A unique symbol identifying the `RuntimeException` type.
|
|
66
|
+
*
|
|
67
|
+
* **Details**
|
|
68
|
+
*
|
|
69
|
+
* This provides a symbol that identifies a `RuntimeException`. This is
|
|
70
|
+
* typically used internally by the library to recognize checked exceptions that
|
|
71
|
+
* occur during runtime.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link RuntimeException} Create or work with a `RuntimeException`
|
|
74
|
+
*
|
|
75
|
+
* @since 2.0.0
|
|
76
|
+
* @category Symbols
|
|
77
|
+
*/
|
|
78
|
+
export const RuntimeExceptionTypeId: unique symbol = core.RuntimeExceptionTypeId
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @since 2.0.0
|
|
82
|
+
* @category Symbols
|
|
83
|
+
*/
|
|
84
|
+
export type RuntimeExceptionTypeId = typeof RuntimeExceptionTypeId
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A unique symbol identifying the `InterruptedException` type.
|
|
88
|
+
*
|
|
89
|
+
* **Details**
|
|
90
|
+
*
|
|
91
|
+
* This provides a symbol that identifies an `InterruptedException`. This is
|
|
92
|
+
* typically used internally to recognize when a fiber has been interrupted,
|
|
93
|
+
* helping the framework handle interruption logic correctly.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link InterruptedException} Create or work with an `InterruptedException`
|
|
96
|
+
*
|
|
97
|
+
* @since 2.0.0
|
|
98
|
+
* @category Symbols
|
|
99
|
+
*/
|
|
100
|
+
export const InterruptedExceptionTypeId: unique symbol = core.InterruptedExceptionTypeId
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @since 2.0.0
|
|
104
|
+
* @category Symbols
|
|
105
|
+
*/
|
|
106
|
+
export type InterruptedExceptionTypeId = typeof InterruptedExceptionTypeId
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A unique symbol identifying the `IllegalArgumentException` type.
|
|
110
|
+
*
|
|
111
|
+
* **Details**
|
|
112
|
+
*
|
|
113
|
+
* This provides a symbol that identifies an `IllegalArgumentException`. This is
|
|
114
|
+
* often used in scenarios where invalid arguments are supplied to methods that
|
|
115
|
+
* expect specific input.
|
|
116
|
+
*
|
|
117
|
+
* @see {@link IllegalArgumentException} Create or work with an `IllegalArgumentException`
|
|
118
|
+
*
|
|
119
|
+
* @since 2.0.0
|
|
120
|
+
* @category Symbols
|
|
121
|
+
*/
|
|
122
|
+
export const IllegalArgumentExceptionTypeId: unique symbol = core.IllegalArgumentExceptionTypeId
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @since 2.0.0
|
|
126
|
+
* @category Symbols
|
|
127
|
+
*/
|
|
128
|
+
export type IllegalArgumentExceptionTypeId = typeof IllegalArgumentExceptionTypeId
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A unique symbol identifying the `NoSuchElementException` type.
|
|
132
|
+
*
|
|
133
|
+
* **Details**
|
|
134
|
+
*
|
|
135
|
+
* This provides a symbol that identifies a `NoSuchElementException`. It helps
|
|
136
|
+
* differentiate cases where a required element is missing within a data
|
|
137
|
+
* structure.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link NoSuchElementException} Create or work with a `NoSuchElementException`
|
|
140
|
+
*
|
|
141
|
+
* @since 2.0.0
|
|
142
|
+
* @category Symbols
|
|
143
|
+
*/
|
|
144
|
+
export const NoSuchElementExceptionTypeId: unique symbol = core.NoSuchElementExceptionTypeId
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @since 2.0.0
|
|
148
|
+
* @category Symbols
|
|
149
|
+
*/
|
|
150
|
+
export type NoSuchElementExceptionTypeId = typeof NoSuchElementExceptionTypeId
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A unique symbol identifying the `InvalidPubSubCapacityException` type.
|
|
154
|
+
*
|
|
155
|
+
* **Details**
|
|
156
|
+
*
|
|
157
|
+
* This provides a symbol that identifies an `InvalidPubSubCapacityException`.
|
|
158
|
+
* It indicates an error related to an invalid capacity passed to a `PubSub`
|
|
159
|
+
* structure.
|
|
160
|
+
*
|
|
161
|
+
* @see {@link InvalidPubSubCapacityException} Create or work with an `InvalidPubSubCapacityException`
|
|
162
|
+
*
|
|
163
|
+
* @since 2.0.0
|
|
164
|
+
* @category Symbols
|
|
165
|
+
*/
|
|
166
|
+
export const InvalidPubSubCapacityExceptionTypeId: unique symbol = core.InvalidPubSubCapacityExceptionTypeId
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @since 2.0.0
|
|
170
|
+
* @category Symbols
|
|
171
|
+
*/
|
|
172
|
+
export type InvalidPubSubCapacityExceptionTypeId = typeof InvalidPubSubCapacityExceptionTypeId
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A unique symbol identifying the `ExceededCapacityException` type.
|
|
176
|
+
*
|
|
177
|
+
* **Details**
|
|
178
|
+
*
|
|
179
|
+
* This provides a symbol that identifies an `ExceededCapacityException`. It
|
|
180
|
+
* denotes situations where a resource has exceeded its configured capacity
|
|
181
|
+
* limit.
|
|
182
|
+
*
|
|
183
|
+
* @see {@link ExceededCapacityException} Create or work with an `ExceededCapacityException`
|
|
184
|
+
*
|
|
185
|
+
* @since 3.5.0
|
|
186
|
+
* @category Symbols
|
|
187
|
+
*/
|
|
188
|
+
export const ExceededCapacityExceptionTypeId: unique symbol = core.ExceededCapacityExceptionTypeId
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @since 3.5.0
|
|
192
|
+
* @category Symbols
|
|
193
|
+
*/
|
|
194
|
+
export type ExceededCapacityExceptionTypeId = typeof ExceededCapacityExceptionTypeId
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A unique symbol identifying the `TimeoutException` type.
|
|
198
|
+
*
|
|
199
|
+
* **Details**
|
|
200
|
+
*
|
|
201
|
+
* This provides a symbol that identifies a `TimeoutException`. It helps the
|
|
202
|
+
* framework recognize errors related to operations that fail to complete within
|
|
203
|
+
* a given timeframe.
|
|
204
|
+
*
|
|
205
|
+
* @see {@link TimeoutException} Create or work with a `TimeoutException`
|
|
206
|
+
*
|
|
207
|
+
* @since 2.0.0
|
|
208
|
+
* @category Symbols
|
|
209
|
+
*/
|
|
210
|
+
export const TimeoutExceptionTypeId: unique symbol = core.TimeoutExceptionTypeId
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @since 2.0.0
|
|
214
|
+
* @category Symbols
|
|
215
|
+
*/
|
|
216
|
+
export type TimeoutExceptionTypeId = typeof TimeoutExceptionTypeId
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* A unique symbol identifying the `UnknownException` type.
|
|
220
|
+
*
|
|
221
|
+
* **Details**
|
|
222
|
+
*
|
|
223
|
+
* This provides a symbol that identifies an `UnknownException`. It is typically
|
|
224
|
+
* used for generic or unexpected errors that do not fit other specific
|
|
225
|
+
* exception categories.
|
|
226
|
+
*
|
|
227
|
+
* @see {@link UnknownException} Create or work with an `UnknownException`
|
|
228
|
+
*
|
|
229
|
+
* @since 2.0.0
|
|
230
|
+
* @category Symbols
|
|
231
|
+
*/
|
|
232
|
+
export const UnknownExceptionTypeId: unique symbol = core.UnknownExceptionTypeId
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @since 2.0.0
|
|
236
|
+
* @category Symbols
|
|
237
|
+
*/
|
|
238
|
+
export type UnknownExceptionTypeId = typeof UnknownExceptionTypeId
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Represents the full history of a failure within an `Effect`.
|
|
242
|
+
*
|
|
243
|
+
* **Details**
|
|
244
|
+
*
|
|
245
|
+
* This type is a data structure that captures all information about why and how
|
|
246
|
+
* an effect has failed, including parallel errors, sequential errors, defects,
|
|
247
|
+
* and interruptions. It enables a "lossless" error model: no error-related
|
|
248
|
+
* information is discarded, which helps in debugging and understanding the root
|
|
249
|
+
* cause of failures.
|
|
250
|
+
*
|
|
251
|
+
* @since 2.0.0
|
|
252
|
+
* @category Models
|
|
253
|
+
*/
|
|
254
|
+
export type Cause<E> =
|
|
255
|
+
| Empty
|
|
256
|
+
| Fail<E>
|
|
257
|
+
| Die
|
|
258
|
+
| Interrupt
|
|
259
|
+
| Sequential<E>
|
|
260
|
+
| Parallel<E>
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @since 2.0.0
|
|
264
|
+
*/
|
|
265
|
+
export declare namespace Cause {
|
|
266
|
+
/**
|
|
267
|
+
* This interface is used internally to manage the type variance of `Cause`.
|
|
268
|
+
*
|
|
269
|
+
* @since 2.0.0
|
|
270
|
+
* @category Models
|
|
271
|
+
*/
|
|
272
|
+
export interface Variance<out E> {
|
|
273
|
+
readonly [CauseTypeId]: {
|
|
274
|
+
readonly _E: Covariant<E>
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Describes methods for reducing a `Cause<E>` into a value of type `Z` with
|
|
281
|
+
* access to contextual information.
|
|
282
|
+
*
|
|
283
|
+
* **Details**
|
|
284
|
+
*
|
|
285
|
+
* This interface is meant for advanced transformations of `Cause`. By
|
|
286
|
+
* implementing each method, you can define how different parts of the `Cause`
|
|
287
|
+
* structure (like `Fail`, `Die`, or `Interrupt`) should be transformed into a
|
|
288
|
+
* final type `Z`. The `context` parameter carries additional data needed during
|
|
289
|
+
* this reduction.
|
|
290
|
+
*
|
|
291
|
+
* @see {@link reduceWithContext} Apply a `CauseReducer` to transform a `Cause`
|
|
292
|
+
*
|
|
293
|
+
* @since 2.0.0
|
|
294
|
+
* @category Models
|
|
295
|
+
*/
|
|
296
|
+
export interface CauseReducer<in C, in E, in out Z> {
|
|
297
|
+
emptyCase(context: C): Z
|
|
298
|
+
failCase(context: C, error: E): Z
|
|
299
|
+
dieCase(context: C, defect: unknown): Z
|
|
300
|
+
interruptCase(context: C, fiberId: FiberId.FiberId): Z
|
|
301
|
+
sequentialCase(context: C, left: Z, right: Z): Z
|
|
302
|
+
parallelCase(context: C, left: Z, right: Z): Z
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Represents an error object that can be yielded in `Effect.gen`.
|
|
307
|
+
*
|
|
308
|
+
* @since 2.0.0
|
|
309
|
+
* @category Models
|
|
310
|
+
*/
|
|
311
|
+
export interface YieldableError extends Pipeable, Inspectable, Error {
|
|
312
|
+
readonly [Effect.EffectTypeId]: Effect.Effect.VarianceStruct<never, this, never>
|
|
313
|
+
readonly [Stream.StreamTypeId]: Stream.Stream.VarianceStruct<never, this, never>
|
|
314
|
+
readonly [Sink.SinkTypeId]: Sink.Sink.VarianceStruct<never, unknown, never, this, never>
|
|
315
|
+
readonly [Channel.ChannelTypeId]: Channel.Channel.VarianceStruct<never, unknown, this, unknown, never, unknown, never>
|
|
316
|
+
[Symbol.iterator](): Effect.EffectGenerator<Effect.Effect<never, this, never>>
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Creates an error that occurs at runtime, extendable for other exception
|
|
321
|
+
* types.
|
|
322
|
+
*
|
|
323
|
+
* @since 2.0.0
|
|
324
|
+
* @category Errors
|
|
325
|
+
*/
|
|
326
|
+
export const YieldableError: new(message?: string | undefined) => YieldableError = core.YieldableError
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* An error representing a runtime error.
|
|
330
|
+
*
|
|
331
|
+
* **Details**
|
|
332
|
+
*
|
|
333
|
+
* This interface is used for errors that occur at runtime but are still
|
|
334
|
+
* considered recoverable or typed.
|
|
335
|
+
*
|
|
336
|
+
* @since 2.0.0
|
|
337
|
+
* @category Models
|
|
338
|
+
*/
|
|
339
|
+
export interface RuntimeException extends YieldableError {
|
|
340
|
+
readonly _tag: "RuntimeException"
|
|
341
|
+
readonly [RuntimeExceptionTypeId]: RuntimeExceptionTypeId
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* An error representing fiber interruption.
|
|
346
|
+
*
|
|
347
|
+
* **Details**
|
|
348
|
+
*
|
|
349
|
+
* This interface represents errors that occur when a fiber is forcefully
|
|
350
|
+
* interrupted. Interruption can happen for various reasons, including
|
|
351
|
+
* cancellations or system directives to halt operations. Code that deals with
|
|
352
|
+
* concurrency might need to catch or handle these to ensure proper cleanup.
|
|
353
|
+
*
|
|
354
|
+
* @since 2.0.0
|
|
355
|
+
* @category Models
|
|
356
|
+
*/
|
|
357
|
+
export interface InterruptedException extends YieldableError {
|
|
358
|
+
readonly _tag: "InterruptedException"
|
|
359
|
+
readonly [InterruptedExceptionTypeId]: InterruptedExceptionTypeId
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* An error representing an invalid argument passed to a method.
|
|
364
|
+
*
|
|
365
|
+
* **Details**
|
|
366
|
+
*
|
|
367
|
+
* This interface is used for signaling that a function or method received an
|
|
368
|
+
* argument that does not meet its preconditions.
|
|
369
|
+
*
|
|
370
|
+
* @since 2.0.0
|
|
371
|
+
* @category Models
|
|
372
|
+
*/
|
|
373
|
+
export interface IllegalArgumentException extends YieldableError {
|
|
374
|
+
readonly _tag: "IllegalArgumentException"
|
|
375
|
+
readonly [IllegalArgumentExceptionTypeId]: IllegalArgumentExceptionTypeId
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* An error that occurs when an expected element is missing.
|
|
380
|
+
*
|
|
381
|
+
* **Details**
|
|
382
|
+
*
|
|
383
|
+
* This interface indicates scenarios like looking up an item in a collection
|
|
384
|
+
* or searching for data that should be present but isn't. It helps your code
|
|
385
|
+
* signal a more specific issue rather than a general error.
|
|
386
|
+
*
|
|
387
|
+
* @since 2.0.0
|
|
388
|
+
* @category Models
|
|
389
|
+
*/
|
|
390
|
+
export interface NoSuchElementException extends YieldableError {
|
|
391
|
+
readonly _tag: "NoSuchElementException"
|
|
392
|
+
readonly [NoSuchElementExceptionTypeId]: NoSuchElementExceptionTypeId
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* An error indicating invalid capacity for a `PubSub`.
|
|
397
|
+
*
|
|
398
|
+
* @since 2.0.0
|
|
399
|
+
* @category Models
|
|
400
|
+
*/
|
|
401
|
+
export interface InvalidPubSubCapacityException extends YieldableError {
|
|
402
|
+
readonly _tag: "InvalidPubSubCapacityException"
|
|
403
|
+
readonly [InvalidPubSubCapacityExceptionTypeId]: InvalidPubSubCapacityExceptionTypeId
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* An error that occurs when resource capacity is exceeded.
|
|
408
|
+
*
|
|
409
|
+
* @since 3.5.0
|
|
410
|
+
* @category Models
|
|
411
|
+
*/
|
|
412
|
+
export interface ExceededCapacityException extends YieldableError {
|
|
413
|
+
readonly _tag: "ExceededCapacityException"
|
|
414
|
+
readonly [ExceededCapacityExceptionTypeId]: ExceededCapacityExceptionTypeId
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* An error representing a computation that timed out.
|
|
419
|
+
*
|
|
420
|
+
* @since 2.0.0
|
|
421
|
+
* @category Models
|
|
422
|
+
*/
|
|
423
|
+
export interface TimeoutException extends YieldableError {
|
|
424
|
+
readonly _tag: "TimeoutException"
|
|
425
|
+
readonly [TimeoutExceptionTypeId]: TimeoutExceptionTypeId
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* A checked exception for handling unknown or unexpected errors.
|
|
430
|
+
*
|
|
431
|
+
* **Details**
|
|
432
|
+
*
|
|
433
|
+
* This interface captures errors that don't fall under known categories. It is
|
|
434
|
+
* especially helpful for wrapping low-level or third-party library errors that
|
|
435
|
+
* might provide little or no context, such as from a rejected promise.
|
|
436
|
+
*
|
|
437
|
+
* @since 2.0.0
|
|
438
|
+
* @category Models
|
|
439
|
+
*/
|
|
440
|
+
export interface UnknownException extends YieldableError {
|
|
441
|
+
readonly _tag: "UnknownException"
|
|
442
|
+
readonly [UnknownExceptionTypeId]: UnknownExceptionTypeId
|
|
443
|
+
readonly error: unknown
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Represents a lack of errors within a `Cause`.
|
|
448
|
+
*
|
|
449
|
+
* @see {@link empty} Construct a new `Empty` cause
|
|
450
|
+
* @see {@link isEmptyType} Check if a `Cause` is an `Empty` type
|
|
451
|
+
*
|
|
452
|
+
* @since 2.0.0
|
|
453
|
+
* @category Models
|
|
454
|
+
*/
|
|
455
|
+
export interface Empty extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspectable {
|
|
456
|
+
readonly _tag: "Empty"
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Represents an expected error within a `Cause`.
|
|
461
|
+
*
|
|
462
|
+
* **Details**
|
|
463
|
+
*
|
|
464
|
+
* This interface models a `Cause` that carries an expected or known error of
|
|
465
|
+
* type `E`. For example, if you validate user input and find it invalid, you
|
|
466
|
+
* might store that error within a `Fail`.
|
|
467
|
+
*
|
|
468
|
+
* @see {@link fail} Construct a `Fail` cause
|
|
469
|
+
* @see {@link isFailType} Check if a `Cause` is a `Fail`
|
|
470
|
+
*
|
|
471
|
+
* @since 2.0.0
|
|
472
|
+
* @category Models
|
|
473
|
+
*/
|
|
474
|
+
export interface Fail<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, Inspectable {
|
|
475
|
+
readonly _tag: "Fail"
|
|
476
|
+
readonly error: E
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Represents an unexpected defect within a `Cause`.
|
|
481
|
+
*
|
|
482
|
+
* **Details**
|
|
483
|
+
*
|
|
484
|
+
* This interface models a `Cause` for errors that are typically unrecoverable or
|
|
485
|
+
* unanticipated—like runtime exceptions or bugs. When code "dies," it indicates a
|
|
486
|
+
* severe failure that wasn't accounted for.
|
|
487
|
+
*
|
|
488
|
+
* @see {@link die} Construct a `Die` cause
|
|
489
|
+
* @see {@link isDieType} Check if a `Cause` is a `Die`
|
|
490
|
+
*
|
|
491
|
+
* @since 2.0.0
|
|
492
|
+
* @category Models
|
|
493
|
+
*/
|
|
494
|
+
export interface Die extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspectable {
|
|
495
|
+
readonly _tag: "Die"
|
|
496
|
+
readonly defect: unknown
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Represents fiber interruption within a `Cause`.
|
|
501
|
+
*
|
|
502
|
+
* **Details**
|
|
503
|
+
*
|
|
504
|
+
* This interface models a scenario where an effect was halted by an external
|
|
505
|
+
* signal, carrying a `FiberId` that identifies which fiber was interrupted.
|
|
506
|
+
* Interruption is a normal part of concurrency, used for cancellation or
|
|
507
|
+
* resource cleanup.
|
|
508
|
+
*
|
|
509
|
+
* @see {@link interrupt} Construct an `Interrupt` cause
|
|
510
|
+
* @see {@link isInterruptType} Check if a `Cause` is an `Interrupt`
|
|
511
|
+
*
|
|
512
|
+
* @since 2.0.0
|
|
513
|
+
* @category Models
|
|
514
|
+
*/
|
|
515
|
+
export interface Interrupt extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspectable {
|
|
516
|
+
readonly _tag: "Interrupt"
|
|
517
|
+
readonly fiberId: FiberId.FiberId
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Represents parallel composition of two `Cause`s.
|
|
522
|
+
*
|
|
523
|
+
* **Details**
|
|
524
|
+
*
|
|
525
|
+
* This interface captures failures that happen simultaneously. In scenarios
|
|
526
|
+
* with concurrency, more than one operation can fail in parallel. Instead of
|
|
527
|
+
* losing information, this structure stores both errors together.
|
|
528
|
+
*
|
|
529
|
+
* @see {@link parallel} Combine two `Cause`s in parallel
|
|
530
|
+
* @see {@link isParallelType} Check if a `Cause` is a `Parallel`
|
|
531
|
+
*
|
|
532
|
+
* @since 2.0.0
|
|
533
|
+
* @category Models
|
|
534
|
+
*/
|
|
535
|
+
export interface Parallel<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, Inspectable {
|
|
536
|
+
readonly _tag: "Parallel"
|
|
537
|
+
readonly left: Cause<E>
|
|
538
|
+
readonly right: Cause<E>
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Represents sequential composition of two `Cause`s.
|
|
543
|
+
*
|
|
544
|
+
* **Details**
|
|
545
|
+
*
|
|
546
|
+
* This interface models the scenario where one error follows another in
|
|
547
|
+
* sequence, such as when a main effect fails and then a finalizer also fails.
|
|
548
|
+
* It ensures both errors are retained in the final `Cause`.
|
|
549
|
+
*
|
|
550
|
+
* @see {@link sequential} Combine two `Cause`s sequentially
|
|
551
|
+
* @see {@link isSequentialType} Check if a `Cause` is a `Sequential`
|
|
552
|
+
*
|
|
553
|
+
* @since 2.0.0
|
|
554
|
+
* @category Models
|
|
555
|
+
*/
|
|
556
|
+
export interface Sequential<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, Inspectable {
|
|
557
|
+
readonly _tag: "Sequential"
|
|
558
|
+
readonly left: Cause<E>
|
|
559
|
+
readonly right: Cause<E>
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Creates an `Empty` cause.
|
|
564
|
+
*
|
|
565
|
+
* **Details**
|
|
566
|
+
*
|
|
567
|
+
* This function returns a cause that signifies "no error." It's commonly used
|
|
568
|
+
* to represent an absence of failure conditions.
|
|
569
|
+
*
|
|
570
|
+
* @see {@link isEmpty} Check if a `Cause` is empty
|
|
571
|
+
*
|
|
572
|
+
* @since 2.0.0
|
|
573
|
+
* @category Constructors
|
|
574
|
+
*/
|
|
575
|
+
export const empty: Cause<never> = internal.empty
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Creates a `Fail` cause from an expected error.
|
|
579
|
+
*
|
|
580
|
+
* **Details**
|
|
581
|
+
*
|
|
582
|
+
* This function constructs a `Cause` carrying an error of type `E`. It's used
|
|
583
|
+
* when you want to represent a known or anticipated failure in your effectful
|
|
584
|
+
* computations.
|
|
585
|
+
*
|
|
586
|
+
* @see {@link isFailure} Check if a `Cause` contains a failure
|
|
587
|
+
*
|
|
588
|
+
* @since 2.0.0
|
|
589
|
+
* @category Constructors
|
|
590
|
+
*/
|
|
591
|
+
export const fail: <E>(error: E) => Cause<E> = internal.fail
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Creates a `Die` cause from an unexpected error.
|
|
595
|
+
*
|
|
596
|
+
* **Details**
|
|
597
|
+
*
|
|
598
|
+
* This function wraps an unhandled or unknown defect (like a runtime crash)
|
|
599
|
+
* into a `Cause`. It's useful for capturing unforeseen issues in a structured
|
|
600
|
+
* way.
|
|
601
|
+
*
|
|
602
|
+
* @see {@link isDie} Check if a `Cause` contains a defect
|
|
603
|
+
*
|
|
604
|
+
* @since 2.0.0
|
|
605
|
+
* @category Constructors
|
|
606
|
+
*/
|
|
607
|
+
export const die: (defect: unknown) => Cause<never> = internal.die
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Creates an `Interrupt` cause from a `FiberId`.
|
|
611
|
+
*
|
|
612
|
+
* **Details**
|
|
613
|
+
*
|
|
614
|
+
* This function represents a fiber that has been interrupted. It stores the
|
|
615
|
+
* identifier of the interrupted fiber, enabling precise tracking of concurrent
|
|
616
|
+
* cancellations.
|
|
617
|
+
*
|
|
618
|
+
* @see {@link isInterrupted} Check if a `Cause` contains an interruption
|
|
619
|
+
*
|
|
620
|
+
* @since 2.0.0
|
|
621
|
+
* @category Constructors
|
|
622
|
+
*/
|
|
623
|
+
export const interrupt: (fiberId: FiberId.FiberId) => Cause<never> = internal.interrupt
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Combines two `Cause`s in parallel.
|
|
627
|
+
*
|
|
628
|
+
* **Details**
|
|
629
|
+
*
|
|
630
|
+
* This function merges two errors that occurred simultaneously. Instead of
|
|
631
|
+
* discarding one error, both are retained, allowing for richer error reporting
|
|
632
|
+
* and debugging.
|
|
633
|
+
*
|
|
634
|
+
* @see {@link isParallelType} Check if a `Cause` is a `Parallel`
|
|
635
|
+
*
|
|
636
|
+
* @since 2.0.0
|
|
637
|
+
* @category Constructors
|
|
638
|
+
*/
|
|
639
|
+
export const parallel: <E, E2>(left: Cause<E>, right: Cause<E2>) => Cause<E | E2> = internal.parallel
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Combines two `Cause`s sequentially.
|
|
643
|
+
*
|
|
644
|
+
* **Details**
|
|
645
|
+
*
|
|
646
|
+
* This function merges two errors that occurred in sequence, such as a main
|
|
647
|
+
* error followed by a finalization error. It preserves both errors for complete
|
|
648
|
+
* failure information.
|
|
649
|
+
*
|
|
650
|
+
* @see {@link isSequentialType} Check if a `Cause` is a `Sequential`
|
|
651
|
+
*
|
|
652
|
+
* @since 2.0.0
|
|
653
|
+
* @category Constructors
|
|
654
|
+
*/
|
|
655
|
+
export const sequential: <E, E2>(left: Cause<E>, right: Cause<E2>) => Cause<E | E2> = internal.sequential
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Checks if a value is a `Cause`.
|
|
659
|
+
*
|
|
660
|
+
* @since 2.0.0
|
|
661
|
+
* @category Guards
|
|
662
|
+
*/
|
|
663
|
+
export const isCause: (u: unknown) => u is Cause<unknown> = internal.isCause
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Checks if a `Cause` is an `Empty` type.
|
|
667
|
+
*
|
|
668
|
+
* @see {@link empty} Create a new `Empty` cause
|
|
669
|
+
*
|
|
670
|
+
* @since 2.0.0
|
|
671
|
+
* @category Guards
|
|
672
|
+
*/
|
|
673
|
+
export const isEmptyType: <E>(self: Cause<E>) => self is Empty = internal.isEmptyType
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Checks if a `Cause` is a `Fail` type.
|
|
677
|
+
*
|
|
678
|
+
* @see {@link fail} Create a new `Fail` cause
|
|
679
|
+
*
|
|
680
|
+
* @since 2.0.0
|
|
681
|
+
* @category Guards
|
|
682
|
+
*/
|
|
683
|
+
export const isFailType: <E>(self: Cause<E>) => self is Fail<E> = internal.isFailType
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Checks if a `Cause` is a `Die` type.
|
|
687
|
+
*
|
|
688
|
+
* @see {@link die} Create a new `Die` cause
|
|
689
|
+
*
|
|
690
|
+
* @since 2.0.0
|
|
691
|
+
* @category Guards
|
|
692
|
+
*/
|
|
693
|
+
export const isDieType: <E>(self: Cause<E>) => self is Die = internal.isDieType
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Checks if a `Cause` is an `Interrupt` type.
|
|
697
|
+
*
|
|
698
|
+
* @see {@link interrupt} Create an `Interrupt` cause
|
|
699
|
+
*
|
|
700
|
+
* @since 2.0.0
|
|
701
|
+
* @category Guards
|
|
702
|
+
*/
|
|
703
|
+
export const isInterruptType: <E>(self: Cause<E>) => self is Interrupt = internal.isInterruptType
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Checks if a `Cause` is a `Sequential` type.
|
|
707
|
+
*
|
|
708
|
+
* @see {@link sequential} Combine two `Cause`s sequentially
|
|
709
|
+
*
|
|
710
|
+
* @since 2.0.0
|
|
711
|
+
* @category Guards
|
|
712
|
+
*/
|
|
713
|
+
export const isSequentialType: <E>(self: Cause<E>) => self is Sequential<E> = internal.isSequentialType
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Checks if a `Cause` is a `Parallel` type.
|
|
717
|
+
*
|
|
718
|
+
* @see {@link parallel} Combine two `Cause`s in parallel
|
|
719
|
+
*
|
|
720
|
+
* @since 2.0.0
|
|
721
|
+
* @category Guards
|
|
722
|
+
*/
|
|
723
|
+
export const isParallelType: <E>(self: Cause<E>) => self is Parallel<E> = internal.isParallelType
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Calculates the size of a `Cause`.
|
|
727
|
+
*
|
|
728
|
+
* **Details**
|
|
729
|
+
*
|
|
730
|
+
* This function returns the total number of `Cause` nodes in the semiring
|
|
731
|
+
* structure, reflecting how many individual error elements are recorded.
|
|
732
|
+
*
|
|
733
|
+
* @since 2.0.0
|
|
734
|
+
* @category Getters
|
|
735
|
+
*/
|
|
736
|
+
export const size: <E>(self: Cause<E>) => number = internal.size
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Checks if a `Cause` is entirely empty.
|
|
740
|
+
*
|
|
741
|
+
* **Details**
|
|
742
|
+
*
|
|
743
|
+
* This function returns `true` if the `Cause` contains no errors, defects, or
|
|
744
|
+
* interruptions. It's helpful for verifying if a computation truly had no
|
|
745
|
+
* failures.
|
|
746
|
+
*
|
|
747
|
+
* @since 2.0.0
|
|
748
|
+
* @category Getters
|
|
749
|
+
*/
|
|
750
|
+
export const isEmpty: <E>(self: Cause<E>) => boolean = internal.isEmpty
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Checks if a `Cause` contains a failure.
|
|
754
|
+
*
|
|
755
|
+
* **Details**
|
|
756
|
+
*
|
|
757
|
+
* This function returns `true` if the `Cause` includes any `Fail` error. It's
|
|
758
|
+
* commonly used to confirm whether a workflow encountered an anticipated error
|
|
759
|
+
* versus just defects or interruptions.
|
|
760
|
+
*
|
|
761
|
+
* @since 2.0.0
|
|
762
|
+
* @category Getters
|
|
763
|
+
*/
|
|
764
|
+
export const isFailure: <E>(self: Cause<E>) => boolean = internal.isFailure
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Checks if a `Cause` contains a defect.
|
|
768
|
+
*
|
|
769
|
+
* **Details**
|
|
770
|
+
*
|
|
771
|
+
* This function returns `true` if the `Cause` includes any unexpected or
|
|
772
|
+
* unhandled errors (`Die`). It's useful for differentiating known failures from
|
|
773
|
+
* unexpected ones.
|
|
774
|
+
*
|
|
775
|
+
* @since 2.0.0
|
|
776
|
+
* @category Getters
|
|
777
|
+
*/
|
|
778
|
+
export const isDie: <E>(self: Cause<E>) => boolean = internal.isDie
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Checks if a `Cause` contains an interruption.
|
|
782
|
+
*
|
|
783
|
+
* **Details**
|
|
784
|
+
*
|
|
785
|
+
* This function returns `true` if the `Cause` includes any fiber interruptions.
|
|
786
|
+
*
|
|
787
|
+
* @since 2.0.0
|
|
788
|
+
* @category Getters
|
|
789
|
+
*/
|
|
790
|
+
export const isInterrupted: <E>(self: Cause<E>) => boolean = internal.isInterrupted
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Checks if a `Cause` contains only interruptions.
|
|
794
|
+
*
|
|
795
|
+
* **Details**
|
|
796
|
+
*
|
|
797
|
+
* This function returns `true` if the `Cause` has been interrupted but does not
|
|
798
|
+
* contain any other failures, such as `Fail` or `Die`. It's helpful for
|
|
799
|
+
* verifying purely "cancellation" scenarios.
|
|
800
|
+
*
|
|
801
|
+
* @since 2.0.0
|
|
802
|
+
* @category Getters
|
|
803
|
+
*/
|
|
804
|
+
export const isInterruptedOnly: <E>(self: Cause<E>) => boolean = internal.isInterruptedOnly
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Extracts all recoverable errors of type `E` from a `Cause`.
|
|
808
|
+
*
|
|
809
|
+
* **Details**
|
|
810
|
+
*
|
|
811
|
+
* This function returns a chunk of errors, providing a list of all `Fail`
|
|
812
|
+
* values found in the cause. It's useful for collecting all known failures for
|
|
813
|
+
* logging or combined error handling.
|
|
814
|
+
*
|
|
815
|
+
* @since 2.0.0
|
|
816
|
+
* @category Getters
|
|
817
|
+
*/
|
|
818
|
+
export const failures: <E>(self: Cause<E>) => Chunk.Chunk<E> = internal.failures
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Extracts all unrecoverable defects from a `Cause`.
|
|
822
|
+
*
|
|
823
|
+
* **Details**
|
|
824
|
+
*
|
|
825
|
+
* This function returns a chunk of values representing unexpected errors
|
|
826
|
+
* (`Die`). It's handy for capturing or logging unanticipated failures that
|
|
827
|
+
* might need special handling, such as bug reports.
|
|
828
|
+
*
|
|
829
|
+
* @since 2.0.0
|
|
830
|
+
* @category Getters
|
|
831
|
+
*/
|
|
832
|
+
export const defects: <E>(self: Cause<E>) => Chunk.Chunk<unknown> = internal.defects
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Collects all `FiberId`s responsible for interrupting a fiber.
|
|
836
|
+
*
|
|
837
|
+
* **Details**
|
|
838
|
+
*
|
|
839
|
+
* This function returns a set of IDs indicating which fibers caused
|
|
840
|
+
* interruptions within this `Cause`. It's useful for debugging concurrency
|
|
841
|
+
* issues or tracing cancellations.
|
|
842
|
+
*
|
|
843
|
+
* @since 2.0.0
|
|
844
|
+
* @category Getters
|
|
845
|
+
*/
|
|
846
|
+
export const interruptors: <E>(self: Cause<E>) => HashSet.HashSet<FiberId.FiberId> = internal.interruptors
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Retrieves the first `Fail` error in a `Cause`, if present.
|
|
850
|
+
*
|
|
851
|
+
* **Details**
|
|
852
|
+
*
|
|
853
|
+
* This function returns an `Option` containing the first recoverable error
|
|
854
|
+
* (`E`) from the cause. It's often used to quickly check if there's a primary
|
|
855
|
+
* error to handle or display.
|
|
856
|
+
*
|
|
857
|
+
* @since 2.0.0
|
|
858
|
+
* @category Getters
|
|
859
|
+
*/
|
|
860
|
+
export const failureOption: <E>(self: Cause<E>) => Option.Option<E> = internal.failureOption
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Splits a `Cause` into either its first `Fail` error or the rest of the cause
|
|
864
|
+
* (which might only contain `Die` or `Interrupt`).
|
|
865
|
+
*
|
|
866
|
+
* **Details**
|
|
867
|
+
*
|
|
868
|
+
* This function either returns the checked error (`E`) or the remaining
|
|
869
|
+
* `Cause<never>` with defects/interruptions. It helps you decide if there's a
|
|
870
|
+
* recoverable path or if only unhandled issues remain.
|
|
871
|
+
*
|
|
872
|
+
* @since 2.0.0
|
|
873
|
+
* @category Getters
|
|
874
|
+
*/
|
|
875
|
+
export const failureOrCause: <E>(self: Cause<E>) => Either.Either<Cause<never>, E> = internal.failureOrCause
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Strips out failures with an error of `None` from a `Cause<Option<E>>`.
|
|
879
|
+
*
|
|
880
|
+
* **Details**
|
|
881
|
+
*
|
|
882
|
+
* This function turns a `Cause<Option<E>>` into an `Option<Cause<E>>`. If the
|
|
883
|
+
* cause only contains failures of `None`, it becomes `None`; otherwise, it
|
|
884
|
+
* returns a `Cause` of the remaining errors. It's helpful when working with
|
|
885
|
+
* optional errors and filtering out certain error paths.
|
|
886
|
+
*
|
|
887
|
+
* @since 2.0.0
|
|
888
|
+
* @category Getters
|
|
889
|
+
*/
|
|
890
|
+
export const flipCauseOption: <E>(self: Cause<Option.Option<E>>) => Option.Option<Cause<E>> = internal.flipCauseOption
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Retrieves the first `Die` defect in a `Cause`, if present.
|
|
894
|
+
*
|
|
895
|
+
* **Details**
|
|
896
|
+
*
|
|
897
|
+
* This function returns an `Option` containing the first unexpected failure
|
|
898
|
+
* (`Die`) discovered. It's helpful for diagnosing the primary defect in a chain
|
|
899
|
+
* of errors.
|
|
900
|
+
*
|
|
901
|
+
* @since 2.0.0
|
|
902
|
+
* @category Getters
|
|
903
|
+
*/
|
|
904
|
+
export const dieOption: <E>(self: Cause<E>) => Option.Option<unknown> = internal.dieOption
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Retrieves the first `Interrupt` in a `Cause`, if present.
|
|
908
|
+
*
|
|
909
|
+
* **Details**
|
|
910
|
+
*
|
|
911
|
+
* This function returns an `Option` with the first fiber interruption
|
|
912
|
+
* discovered. This is particularly useful for concurrency analysis or debugging
|
|
913
|
+
* cancellations.
|
|
914
|
+
*
|
|
915
|
+
* @since 2.0.0
|
|
916
|
+
* @category Getters
|
|
917
|
+
*/
|
|
918
|
+
export const interruptOption: <E>(self: Cause<E>) => Option.Option<FiberId.FiberId> = internal.interruptOption
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Removes all `Fail` and `Interrupt` nodes, keeping only defects (`Die`) in a
|
|
922
|
+
* `Cause`.
|
|
923
|
+
*
|
|
924
|
+
* **Details**
|
|
925
|
+
*
|
|
926
|
+
* This function strips a cause of recoverable errors and interruptions, leaving
|
|
927
|
+
* only unexpected failures. If no defects remain, it returns `None`. It's
|
|
928
|
+
* valuable for focusing only on unanticipated problems when both known errors
|
|
929
|
+
* and defects could occur.
|
|
930
|
+
*
|
|
931
|
+
* @since 2.0.0
|
|
932
|
+
* @category Getters
|
|
933
|
+
*/
|
|
934
|
+
export const keepDefects: <E>(self: Cause<E>) => Option.Option<Cause<never>> = internal.keepDefects
|
|
935
|
+
|
|
936
|
+
// TODO(4.0): remove? what's the point of this API?
|
|
937
|
+
/**
|
|
938
|
+
* Linearizes a `Cause` into a set of parallel causes, each containing a
|
|
939
|
+
* sequential chain of failures.
|
|
940
|
+
*
|
|
941
|
+
* **Details**
|
|
942
|
+
*
|
|
943
|
+
* This function reorganizes the cause structure so that you can analyze each
|
|
944
|
+
* parallel branch separately, even if they have multiple sequential errors.
|
|
945
|
+
*
|
|
946
|
+
* @since 2.0.0
|
|
947
|
+
* @category Getters
|
|
948
|
+
*/
|
|
949
|
+
export const linearize: <E>(self: Cause<E>) => HashSet.HashSet<Cause<E>> = internal.linearize
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Removes `Fail` and `Interrupt` nodes from a `Cause`, keeping only defects
|
|
953
|
+
* (`Die`).
|
|
954
|
+
*
|
|
955
|
+
* **Details**
|
|
956
|
+
*
|
|
957
|
+
* This function is similar to `keepDefects` but returns a `Cause<never>`
|
|
958
|
+
* directly, which can still store `Die` or finalizer-related defects. It's
|
|
959
|
+
* helpful for analyzing only the irrecoverable portion of the error.
|
|
960
|
+
*
|
|
961
|
+
* @since 2.0.0
|
|
962
|
+
* @category Getters
|
|
963
|
+
*/
|
|
964
|
+
export const stripFailures: <E>(self: Cause<E>) => Cause<never> = internal.stripFailures
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Removes matching defects from a `Cause` using a partial function, returning
|
|
968
|
+
* the remainder.
|
|
969
|
+
*
|
|
970
|
+
* **Details**
|
|
971
|
+
*
|
|
972
|
+
* This function applies a user-defined extraction function to each defect
|
|
973
|
+
* (`Die`). If the function matches the defect, that defect is removed. If all
|
|
974
|
+
* defects match, the result is `None`. Otherwise, you get a `Cause` with the
|
|
975
|
+
* unmatched defects.
|
|
976
|
+
*
|
|
977
|
+
* @since 2.0.0
|
|
978
|
+
* @category Getters
|
|
979
|
+
*/
|
|
980
|
+
export const stripSomeDefects: {
|
|
981
|
+
(pf: (defect: unknown) => Option.Option<unknown>): <E>(self: Cause<E>) => Option.Option<Cause<E>>
|
|
982
|
+
<E>(self: Cause<E>, pf: (defect: unknown) => Option.Option<unknown>): Option.Option<Cause<E>>
|
|
983
|
+
} = internal.stripSomeDefects
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Replaces any errors in a `Cause` with a provided constant error.
|
|
987
|
+
*
|
|
988
|
+
* **Details**
|
|
989
|
+
*
|
|
990
|
+
* This function transforms all `Fail` errors into the specified error value,
|
|
991
|
+
* preserving the structure of the `Cause`. It's useful when you no longer need
|
|
992
|
+
* the original error details but still want to keep the cause shape.
|
|
993
|
+
*
|
|
994
|
+
* @see {@link map} Apply a custom transformation to `Fail` errors
|
|
995
|
+
*
|
|
996
|
+
* @since 2.0.0
|
|
997
|
+
* @category Mapping
|
|
998
|
+
*/
|
|
999
|
+
export const as: {
|
|
1000
|
+
<E2>(error: E2): <E>(self: Cause<E>) => Cause<E2>
|
|
1001
|
+
<E, E2>(self: Cause<E>, error: E2): Cause<E2>
|
|
1002
|
+
} = internal.as
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Transforms the errors in a `Cause` using a user-provided function.
|
|
1006
|
+
*
|
|
1007
|
+
* **Details**
|
|
1008
|
+
*
|
|
1009
|
+
* This function applies `f` to each `Fail` error while leaving defects (`Die`)
|
|
1010
|
+
* and interruptions untouched. It's useful for changing or simplifying error
|
|
1011
|
+
* types in your effectful workflows.
|
|
1012
|
+
*
|
|
1013
|
+
* @see {@link as} Replace errors with a single constant
|
|
1014
|
+
*
|
|
1015
|
+
* @since 2.0.0
|
|
1016
|
+
* @category Mapping
|
|
1017
|
+
*/
|
|
1018
|
+
export const map: {
|
|
1019
|
+
<E, E2>(f: (e: E) => E2): (self: Cause<E>) => Cause<E2>
|
|
1020
|
+
<E, E2>(self: Cause<E>, f: (e: E) => E2): Cause<E2>
|
|
1021
|
+
} = internal.map
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Transforms errors in a `Cause` into new causes.
|
|
1025
|
+
*
|
|
1026
|
+
* **Details**
|
|
1027
|
+
*
|
|
1028
|
+
* This function applies a function `f` to each `Fail` error, converting it into
|
|
1029
|
+
* a new `Cause`. This is especially powerful for merging or restructuring error
|
|
1030
|
+
* types while preserving or combining cause information.
|
|
1031
|
+
*
|
|
1032
|
+
* @see {@link map} Apply a simpler transformation to errors
|
|
1033
|
+
*
|
|
1034
|
+
* @since 2.0.0
|
|
1035
|
+
* @category Sequencing
|
|
1036
|
+
*/
|
|
1037
|
+
export const flatMap: {
|
|
1038
|
+
<E, E2>(f: (e: E) => Cause<E2>): (self: Cause<E>) => Cause<E2>
|
|
1039
|
+
<E, E2>(self: Cause<E>, f: (e: E) => Cause<E2>): Cause<E2>
|
|
1040
|
+
} = internal.flatMap
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
1044
|
+
* the first `Cause`.
|
|
1045
|
+
*
|
|
1046
|
+
* @since 2.0.0
|
|
1047
|
+
* @category Sequencing
|
|
1048
|
+
*/
|
|
1049
|
+
export const andThen: {
|
|
1050
|
+
<E, E2>(f: (e: E) => Cause<E2>): (self: Cause<E>) => Cause<E2>
|
|
1051
|
+
<E2>(f: Cause<E2>): <E>(self: Cause<E>) => Cause<E2>
|
|
1052
|
+
<E, E2>(self: Cause<E>, f: (e: E) => Cause<E2>): Cause<E2>
|
|
1053
|
+
<E, E2>(self: Cause<E>, f: Cause<E2>): Cause<E2>
|
|
1054
|
+
} = internal.andThen
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Flattens a nested `Cause` structure.
|
|
1058
|
+
*
|
|
1059
|
+
* **Details**
|
|
1060
|
+
*
|
|
1061
|
+
* This function takes a `Cause<Cause<E>>` and merges the layers into a single
|
|
1062
|
+
* `Cause<E>`. It's useful for eliminating additional nesting created by
|
|
1063
|
+
* repeated transformations or compositions.
|
|
1064
|
+
*
|
|
1065
|
+
* @see {@link flatMap} Compose nested causes
|
|
1066
|
+
*
|
|
1067
|
+
* @since 2.0.0
|
|
1068
|
+
* @category Sequencing
|
|
1069
|
+
*/
|
|
1070
|
+
export const flatten: <E>(self: Cause<Cause<E>>) => Cause<E> = internal.flatten
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Checks if the current `Cause` contains or is equal to another `Cause`.
|
|
1074
|
+
*
|
|
1075
|
+
* **Details**
|
|
1076
|
+
*
|
|
1077
|
+
* This function returns `true` if `that` cause is part of or the same as
|
|
1078
|
+
* the current `Cause`. It's useful when you need to check for specific
|
|
1079
|
+
* error patterns or deduplicate repeated failures.
|
|
1080
|
+
*
|
|
1081
|
+
* @since 2.0.0
|
|
1082
|
+
* @category Elements
|
|
1083
|
+
*/
|
|
1084
|
+
export const contains: {
|
|
1085
|
+
<E2>(that: Cause<E2>): <E>(self: Cause<E>) => boolean
|
|
1086
|
+
<E, E2>(self: Cause<E>, that: Cause<E2>): boolean
|
|
1087
|
+
} = internal.contains
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Extracts the most "important" defect from a `Cause`.
|
|
1091
|
+
*
|
|
1092
|
+
* **Details**
|
|
1093
|
+
*
|
|
1094
|
+
* This function reduces a `Cause` to a single, prioritized defect. It evaluates
|
|
1095
|
+
* the `Cause` in the following order of priority:
|
|
1096
|
+
*
|
|
1097
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it returns
|
|
1098
|
+
* the raw error value.
|
|
1099
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
1100
|
+
* `Effect.die`).
|
|
1101
|
+
* 3. If neither of the above is present, and the `Cause` stems from an
|
|
1102
|
+
* interruption, it creates and returns an `InterruptedException`.
|
|
1103
|
+
*
|
|
1104
|
+
* This function ensures you can always extract a meaningful representation of
|
|
1105
|
+
* the primary issue from a potentially complex `Cause` structure.
|
|
1106
|
+
*
|
|
1107
|
+
* **When to Use**
|
|
1108
|
+
*
|
|
1109
|
+
* Use this function when you need to extract the most relevant error or defect
|
|
1110
|
+
* from a `Cause`, especially in scenarios where multiple errors or defects may
|
|
1111
|
+
* be present. It's particularly useful for simplifying error reporting or
|
|
1112
|
+
* logging.
|
|
1113
|
+
*
|
|
1114
|
+
* @see {@link squashWith} Allows transforming failures into defects when squashing.
|
|
1115
|
+
*
|
|
1116
|
+
* @since 2.0.0
|
|
1117
|
+
* @category Destructors
|
|
1118
|
+
*/
|
|
1119
|
+
export const squash: <E>(self: Cause<E>) => unknown = core.causeSquash
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Extracts the most "important" defect from a `Cause`, transforming failures
|
|
1123
|
+
* into defects using a provided function.
|
|
1124
|
+
*
|
|
1125
|
+
* **Details**
|
|
1126
|
+
*
|
|
1127
|
+
* This function reduces a `Cause` to a single, prioritized defect, while
|
|
1128
|
+
* allowing you to transform recoverable failures into defects through a custom
|
|
1129
|
+
* function. It processes the `Cause` in the following order:
|
|
1130
|
+
*
|
|
1131
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it applies
|
|
1132
|
+
* the provided function `f` to the error to transform it into a defect.
|
|
1133
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
1134
|
+
* `Effect.die`) and returns it.
|
|
1135
|
+
* 3. If neither is present and the `Cause` stems from an interruption, it
|
|
1136
|
+
* returns an `InterruptedException`.
|
|
1137
|
+
*
|
|
1138
|
+
* This function is particularly useful when you need custom handling or
|
|
1139
|
+
* transformation of errors while processing a `Cause`.
|
|
1140
|
+
*
|
|
1141
|
+
* @see {@link squash} Extracts the most "important" defect without transforming failures.
|
|
1142
|
+
*
|
|
1143
|
+
* @since 2.0.0
|
|
1144
|
+
* @category Destructors
|
|
1145
|
+
*/
|
|
1146
|
+
export const squashWith: {
|
|
1147
|
+
<E>(f: (error: E) => unknown): (self: Cause<E>) => unknown
|
|
1148
|
+
<E>(self: Cause<E>, f: (error: E) => unknown): unknown
|
|
1149
|
+
} = core.causeSquashWith
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* Searches a `Cause` using a partial function to extract information.
|
|
1153
|
+
*
|
|
1154
|
+
* **Details**
|
|
1155
|
+
*
|
|
1156
|
+
* This function allows you to search through a `Cause` using a custom partial
|
|
1157
|
+
* function. The partial function is applied to the `Cause`, and if it matches,
|
|
1158
|
+
* the result is returned wrapped in a `Some`. If no match is found, the result
|
|
1159
|
+
* is `None`.
|
|
1160
|
+
*
|
|
1161
|
+
* This is particularly useful when you are only interested in specific types of
|
|
1162
|
+
* errors, defects, or interruption causes within a potentially complex `Cause`
|
|
1163
|
+
* structure. By leveraging a partial function, you can focus on extracting only
|
|
1164
|
+
* the relevant information you care about.
|
|
1165
|
+
*
|
|
1166
|
+
* The partial function should return an `Option` indicating whether it matched
|
|
1167
|
+
* and the value it extracted.
|
|
1168
|
+
*
|
|
1169
|
+
* @since 2.0.0
|
|
1170
|
+
* @category Elements
|
|
1171
|
+
*/
|
|
1172
|
+
export const find: {
|
|
1173
|
+
<E, Z>(pf: (cause: Cause<E>) => Option.Option<Z>): (self: Cause<E>) => Option.Option<Z>
|
|
1174
|
+
<E, Z>(self: Cause<E>, pf: (cause: Cause<E>) => Option.Option<Z>): Option.Option<Z>
|
|
1175
|
+
} = internal.find
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
1179
|
+
*
|
|
1180
|
+
* **Details**
|
|
1181
|
+
*
|
|
1182
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
1183
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
1184
|
+
* not match the provided condition are excluded from the result.
|
|
1185
|
+
*
|
|
1186
|
+
* You can use this function in two ways:
|
|
1187
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
1188
|
+
* retained based on its value.
|
|
1189
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
1190
|
+
* the `Cause`.
|
|
1191
|
+
*
|
|
1192
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
1193
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
1194
|
+
*
|
|
1195
|
+
* @since 2.0.0
|
|
1196
|
+
* @category Filtering
|
|
1197
|
+
*/
|
|
1198
|
+
export const filter: {
|
|
1199
|
+
<E, EB extends E>(refinement: Refinement<Cause<NoInfer<E>>, Cause<EB>>): (self: Cause<E>) => Cause<EB>
|
|
1200
|
+
<E>(predicate: Predicate<Cause<NoInfer<E>>>): (self: Cause<E>) => Cause<E>
|
|
1201
|
+
<E, EB extends E>(self: Cause<E>, refinement: Refinement<Cause<E>, Cause<EB>>): Cause<EB>
|
|
1202
|
+
<E>(self: Cause<E>, predicate: Predicate<Cause<E>>): Cause<E>
|
|
1203
|
+
} = internal.filter
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Transforms a `Cause` into a single value using custom handlers for each
|
|
1207
|
+
* possible case.
|
|
1208
|
+
*
|
|
1209
|
+
* **Details**
|
|
1210
|
+
*
|
|
1211
|
+
* This function processes a `Cause` by applying a set of custom handlers to
|
|
1212
|
+
* each possible type of cause: `Empty`, `Fail`, `Die`, `Interrupt`,
|
|
1213
|
+
* `Sequential`, and `Parallel`. The result of this function is a single value
|
|
1214
|
+
* of type `Z`. This function allows you to define exactly how to handle each
|
|
1215
|
+
* part of a `Cause`, whether it's a failure, defect, interruption, or a
|
|
1216
|
+
* combination of these.
|
|
1217
|
+
*
|
|
1218
|
+
* The options parameter provides handlers for:
|
|
1219
|
+
* - `onEmpty`: Handles the case where the cause is `Empty`, meaning no errors
|
|
1220
|
+
* occurred.
|
|
1221
|
+
* - `onFail`: Processes a failure with an error of type `E`.
|
|
1222
|
+
* - `onDie`: Processes a defect (unexpected error).
|
|
1223
|
+
* - `onInterrupt`: Handles a fiber interruption, providing the `FiberId` of the
|
|
1224
|
+
* interruption.
|
|
1225
|
+
* - `onSequential`: Combines two sequential causes into a single value of type
|
|
1226
|
+
* `Z`.
|
|
1227
|
+
* - `onParallel`: Combines two parallel causes into a single value of type `Z`.
|
|
1228
|
+
*
|
|
1229
|
+
* @since 2.0.0
|
|
1230
|
+
* @category Matching
|
|
1231
|
+
*/
|
|
1232
|
+
export const match: {
|
|
1233
|
+
<Z, E>(
|
|
1234
|
+
options: {
|
|
1235
|
+
readonly onEmpty: Z
|
|
1236
|
+
readonly onFail: (error: E) => Z
|
|
1237
|
+
readonly onDie: (defect: unknown) => Z
|
|
1238
|
+
readonly onInterrupt: (fiberId: FiberId.FiberId) => Z
|
|
1239
|
+
readonly onSequential: (left: Z, right: Z) => Z
|
|
1240
|
+
readonly onParallel: (left: Z, right: Z) => Z
|
|
1241
|
+
}
|
|
1242
|
+
): (self: Cause<E>) => Z
|
|
1243
|
+
<Z, E>(
|
|
1244
|
+
self: Cause<E>,
|
|
1245
|
+
options: {
|
|
1246
|
+
readonly onEmpty: Z
|
|
1247
|
+
readonly onFail: (error: E) => Z
|
|
1248
|
+
readonly onDie: (defect: unknown) => Z
|
|
1249
|
+
readonly onInterrupt: (fiberId: FiberId.FiberId) => Z
|
|
1250
|
+
readonly onSequential: (left: Z, right: Z) => Z
|
|
1251
|
+
readonly onParallel: (left: Z, right: Z) => Z
|
|
1252
|
+
}
|
|
1253
|
+
): Z
|
|
1254
|
+
} = internal.match
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Combines all parts of a `Cause` into a single value by starting with an
|
|
1258
|
+
* initial value.
|
|
1259
|
+
*
|
|
1260
|
+
* **Details**
|
|
1261
|
+
*
|
|
1262
|
+
* This function processes a `Cause` by starting with an initial value (`zero`)
|
|
1263
|
+
* and applying a custom function (`pf`) to combine all elements of the `Cause`
|
|
1264
|
+
* into a single result of type `Z`. The custom function determines how each
|
|
1265
|
+
* part of the `Cause` contributes to the final result. The function can return
|
|
1266
|
+
* an `Option` to either continue combining values or skip specific parts of the
|
|
1267
|
+
* `Cause`.
|
|
1268
|
+
*
|
|
1269
|
+
* This function is useful for tasks such as:
|
|
1270
|
+
* - Aggregating error messages from a `Cause` into a single string.
|
|
1271
|
+
* - Summarizing the structure of a `Cause` into a simplified result.
|
|
1272
|
+
* - Filtering or processing only specific parts of a `Cause`.
|
|
1273
|
+
*
|
|
1274
|
+
* The reduction proceeds in a top-down manner, visiting all nodes in the
|
|
1275
|
+
* `Cause` structure. This gives you complete control over how each part of the
|
|
1276
|
+
* `Cause` contributes to the final result.
|
|
1277
|
+
*
|
|
1278
|
+
* @since 2.0.0
|
|
1279
|
+
* @category Reducing
|
|
1280
|
+
*/
|
|
1281
|
+
export const reduce: {
|
|
1282
|
+
<Z, E>(zero: Z, pf: (accumulator: Z, cause: Cause<E>) => Option.Option<Z>): (self: Cause<E>) => Z
|
|
1283
|
+
<Z, E>(self: Cause<E>, zero: Z, pf: (accumulator: Z, cause: Cause<E>) => Option.Option<Z>): Z
|
|
1284
|
+
} = internal.reduce
|
|
1285
|
+
|
|
1286
|
+
/**
|
|
1287
|
+
* Combines all parts of a `Cause` into a single value using a custom reducer
|
|
1288
|
+
* and a context.
|
|
1289
|
+
*
|
|
1290
|
+
* **Details**
|
|
1291
|
+
*
|
|
1292
|
+
* This function allows you to reduce a `Cause` into a single value of type `Z`
|
|
1293
|
+
* using a custom `CauseReducer`. A `CauseReducer` provides methods to handle
|
|
1294
|
+
* specific parts of the `Cause`, such as failures, defects, or interruptions.
|
|
1295
|
+
* Additionally, this function provides access to a `context` value, which can
|
|
1296
|
+
* be used to carry information or maintain state during the reduction process.
|
|
1297
|
+
*
|
|
1298
|
+
* This is particularly useful when the reduction process needs additional
|
|
1299
|
+
* context or configuration, such as:
|
|
1300
|
+
* - Aggregating error details with dynamic formatting.
|
|
1301
|
+
* - Collecting logs or statistics about the `Cause`.
|
|
1302
|
+
* - Performing stateful transformations based on the `context`.
|
|
1303
|
+
*
|
|
1304
|
+
* @see {@link reduce} To reduce a `Cause` without additional context.
|
|
1305
|
+
*
|
|
1306
|
+
* @since 2.0.0
|
|
1307
|
+
* @category Reducing
|
|
1308
|
+
*/
|
|
1309
|
+
export const reduceWithContext: {
|
|
1310
|
+
<C, E, Z>(context: C, reducer: CauseReducer<C, E, Z>): (self: Cause<E>) => Z
|
|
1311
|
+
<C, E, Z>(self: Cause<E>, context: C, reducer: CauseReducer<C, E, Z>): Z
|
|
1312
|
+
} = internal.reduceWithContext
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* Creates an error that indicates a `Fiber` was interrupted.
|
|
1316
|
+
*
|
|
1317
|
+
* **Details**
|
|
1318
|
+
*
|
|
1319
|
+
* This function constructs an `InterruptedException` recognized by the Effect
|
|
1320
|
+
* runtime. It is usually thrown or returned when a fiber's execution is
|
|
1321
|
+
* interrupted by external events or by another fiber. This is particularly
|
|
1322
|
+
* helpful in concurrent programs where fibers may halt each other before
|
|
1323
|
+
* completion.
|
|
1324
|
+
*
|
|
1325
|
+
* @since 2.0.0
|
|
1326
|
+
* @category Errors
|
|
1327
|
+
*/
|
|
1328
|
+
export const InterruptedException: new(message?: string | undefined) => InterruptedException = core.InterruptedException
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Checks if a given unknown value is an `InterruptedException`.
|
|
1332
|
+
*
|
|
1333
|
+
* @since 2.0.0
|
|
1334
|
+
* @category Guards
|
|
1335
|
+
*/
|
|
1336
|
+
export const isInterruptedException: (u: unknown) => u is InterruptedException = core.isInterruptedException
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Creates an error indicating an invalid method argument.
|
|
1340
|
+
*
|
|
1341
|
+
* **Details**
|
|
1342
|
+
*
|
|
1343
|
+
* This function constructs an `IllegalArgumentException`. It is typically
|
|
1344
|
+
* thrown or returned when an operation receives improper inputs, such as
|
|
1345
|
+
* out-of-range values or invalid object states.
|
|
1346
|
+
*
|
|
1347
|
+
* @since 2.0.0
|
|
1348
|
+
* @category Errors
|
|
1349
|
+
*/
|
|
1350
|
+
export const IllegalArgumentException: new(message?: string | undefined) => IllegalArgumentException =
|
|
1351
|
+
core.IllegalArgumentException
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* Checks if a given unknown value is an `IllegalArgumentException`.
|
|
1355
|
+
*
|
|
1356
|
+
* @since 2.0.0
|
|
1357
|
+
* @category Guards
|
|
1358
|
+
*/
|
|
1359
|
+
export const isIllegalArgumentException: (u: unknown) => u is IllegalArgumentException = core.isIllegalArgumentException
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Creates an error indicating a missing element.
|
|
1363
|
+
*
|
|
1364
|
+
* **Details**
|
|
1365
|
+
*
|
|
1366
|
+
* This function constructs a `NoSuchElementException`. It helps you clearly
|
|
1367
|
+
* communicate that a required element is unavailable.
|
|
1368
|
+
*
|
|
1369
|
+
* @since 2.0.0
|
|
1370
|
+
* @category Errors
|
|
1371
|
+
*/
|
|
1372
|
+
export const NoSuchElementException: new(message?: string | undefined) => NoSuchElementException =
|
|
1373
|
+
core.NoSuchElementException
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Checks if a given unknown value is a `NoSuchElementException`.
|
|
1377
|
+
*
|
|
1378
|
+
* @since 2.0.0
|
|
1379
|
+
* @category Guards
|
|
1380
|
+
*/
|
|
1381
|
+
export const isNoSuchElementException: (u: unknown) => u is NoSuchElementException = core.isNoSuchElementException
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Creates an error for general runtime errors.
|
|
1385
|
+
*
|
|
1386
|
+
* **Details**
|
|
1387
|
+
*
|
|
1388
|
+
* This function constructs a `RuntimeException`, for errors that occur at
|
|
1389
|
+
* runtime but are not specifically typed or categorized as interruptions,
|
|
1390
|
+
* missing elements, or invalid arguments. It helps unify a wide range of
|
|
1391
|
+
* unexpected conditions under a single, recognizable error type.
|
|
1392
|
+
*
|
|
1393
|
+
* @since 2.0.0
|
|
1394
|
+
* @category Errors
|
|
1395
|
+
*/
|
|
1396
|
+
export const RuntimeException: new(message?: string | undefined) => RuntimeException = core.RuntimeException
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* Checks if a given unknown value is a `RuntimeException`.
|
|
1400
|
+
*
|
|
1401
|
+
* @since 2.0.0
|
|
1402
|
+
* @category Guards
|
|
1403
|
+
*/
|
|
1404
|
+
export const isRuntimeException: (u: unknown) => u is RuntimeException = core.isRuntimeException
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* Creates an error for operations that exceed their expected time.
|
|
1408
|
+
*
|
|
1409
|
+
* **Details**
|
|
1410
|
+
*
|
|
1411
|
+
* This function constructs a `TimeoutException`. It is typically used to signal
|
|
1412
|
+
* that an operation or fiber did not complete within a designated time limit,
|
|
1413
|
+
* allowing you to handle slow or hanging processes.
|
|
1414
|
+
*
|
|
1415
|
+
* @since 2.0.0
|
|
1416
|
+
* @category Errors
|
|
1417
|
+
*/
|
|
1418
|
+
export const TimeoutException: new(message?: string | undefined) => TimeoutException = core.TimeoutException
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Checks if a given unknown value is a `TimeoutException`.
|
|
1422
|
+
*
|
|
1423
|
+
* @since 3.15.0
|
|
1424
|
+
* @category Guards
|
|
1425
|
+
*/
|
|
1426
|
+
export const isTimeoutException: (u: unknown) => u is TimeoutException = core.isTimeoutException
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Creates an instance of `UnknownException`, an error object used to handle
|
|
1430
|
+
* unknown errors such as those from rejected promises.
|
|
1431
|
+
*
|
|
1432
|
+
* **Details**
|
|
1433
|
+
*
|
|
1434
|
+
* This function constructs an `UnknownException` with flexible behavior for
|
|
1435
|
+
* managing the error message and cause.
|
|
1436
|
+
*
|
|
1437
|
+
* The required `error` argument is passed as the `cause` to the global `Error`
|
|
1438
|
+
* constructor, ensuring that the original cause is preserved in the error chain
|
|
1439
|
+
* for debugging purposes. This ensures that the origin stack trace is
|
|
1440
|
+
* preserved.
|
|
1441
|
+
*
|
|
1442
|
+
* The `error` argument is always stored in the `error` property of the
|
|
1443
|
+
* `UnknownException` instance for reference, regardless of its type.
|
|
1444
|
+
*
|
|
1445
|
+
* Additionally, if you provide a `message` argument, it is used as the error
|
|
1446
|
+
* message. If no `message` is provided, the error message defaults to `"An
|
|
1447
|
+
* unknown error occurred"`.
|
|
1448
|
+
*
|
|
1449
|
+
* **When to Use**
|
|
1450
|
+
*
|
|
1451
|
+
* Use this function when you need to handle unexpected or unknown errors in
|
|
1452
|
+
* your application, particularly when the source of the error might not provide
|
|
1453
|
+
* a clear message. This is useful for wrapping generic errors thrown from
|
|
1454
|
+
* promises or external APIs.
|
|
1455
|
+
*
|
|
1456
|
+
* @since 2.0.0
|
|
1457
|
+
* @category Errors
|
|
1458
|
+
*/
|
|
1459
|
+
export const UnknownException: new(error: unknown, message?: string | undefined) => UnknownException =
|
|
1460
|
+
core.UnknownException
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Checks if a given unknown value is an `UnknownException`.
|
|
1464
|
+
*
|
|
1465
|
+
* @since 2.0.0
|
|
1466
|
+
* @category Guards
|
|
1467
|
+
*/
|
|
1468
|
+
export const isUnknownException: (u: unknown) => u is UnknownException = core.isUnknownException
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* Creates an error indicating resource capacity has been exceeded.
|
|
1472
|
+
*
|
|
1473
|
+
* **Details**
|
|
1474
|
+
*
|
|
1475
|
+
* This function constructs an `ExceededCapacityException`, signifying that an
|
|
1476
|
+
* operation or resource usage surpassed established limits. This can be
|
|
1477
|
+
* essential for concurrency or resource management situations, ensuring your
|
|
1478
|
+
* application doesn't go beyond acceptable thresholds.
|
|
1479
|
+
*
|
|
1480
|
+
* @since 3.5.0
|
|
1481
|
+
* @category Errors
|
|
1482
|
+
*/
|
|
1483
|
+
export const ExceededCapacityException: new(message?: string | undefined) => ExceededCapacityException =
|
|
1484
|
+
core.ExceededCapacityException
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Checks if a given unknown value is an `ExceededCapacityException`.
|
|
1488
|
+
*
|
|
1489
|
+
* @since 3.5.0
|
|
1490
|
+
* @category Guards
|
|
1491
|
+
*/
|
|
1492
|
+
export const isExceededCapacityException: (u: unknown) => u is ExceededCapacityException =
|
|
1493
|
+
core.isExceededCapacityException
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Converts a `Cause` into a human-readable string.
|
|
1497
|
+
*
|
|
1498
|
+
* **Details**
|
|
1499
|
+
*
|
|
1500
|
+
* This function pretty-prints the entire `Cause`, including any failures,
|
|
1501
|
+
* defects, and interruptions. It can be especially helpful for logging,
|
|
1502
|
+
* debugging, or displaying structured errors to users.
|
|
1503
|
+
*
|
|
1504
|
+
* You can optionally pass `options` to configure how the error cause is
|
|
1505
|
+
* rendered. By default, it includes essential details of all errors in the
|
|
1506
|
+
* `Cause`.
|
|
1507
|
+
*
|
|
1508
|
+
* @see {@link prettyErrors} Get a list of `PrettyError` objects instead of a single string.
|
|
1509
|
+
*
|
|
1510
|
+
* @since 2.0.0
|
|
1511
|
+
* @category Formatting
|
|
1512
|
+
*/
|
|
1513
|
+
export const pretty: <E>(cause: Cause<E>, options?: {
|
|
1514
|
+
readonly renderErrorCause?: boolean | undefined
|
|
1515
|
+
}) => string = internal.pretty
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* A shape for prettified errors, optionally including a source span.
|
|
1519
|
+
*
|
|
1520
|
+
* @since 3.2.0
|
|
1521
|
+
* @category Models
|
|
1522
|
+
*/
|
|
1523
|
+
export interface PrettyError extends Error {
|
|
1524
|
+
readonly span: Span | undefined
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Returns a list of prettified errors (`PrettyError`) from a `Cause`.
|
|
1529
|
+
*
|
|
1530
|
+
* **Details**
|
|
1531
|
+
*
|
|
1532
|
+
* This function inspects the entire `Cause` and produces an array of
|
|
1533
|
+
* `PrettyError` objects. Each object may include additional metadata, such as a
|
|
1534
|
+
* `Span`, to provide deeper insights into where and how the error occurred.
|
|
1535
|
+
*
|
|
1536
|
+
* @since 3.2.0
|
|
1537
|
+
* @category Formatting
|
|
1538
|
+
*/
|
|
1539
|
+
export const prettyErrors: <E>(cause: Cause<E>) => Array<PrettyError> = internal.prettyErrors
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* Retrieves the original, unproxied error instance from an error object.
|
|
1543
|
+
*
|
|
1544
|
+
* **Details**
|
|
1545
|
+
*
|
|
1546
|
+
* This function returns the underlying error object without any
|
|
1547
|
+
* library-specific wrapping or proxying that might occur during error handling.
|
|
1548
|
+
* This can be essential if you need direct access to the error's native
|
|
1549
|
+
* properties, such as stack traces or custom data fields, for detailed
|
|
1550
|
+
* debugging or integration with external systems.
|
|
1551
|
+
*
|
|
1552
|
+
* @since 2.0.0
|
|
1553
|
+
* @category Errors
|
|
1554
|
+
*/
|
|
1555
|
+
export const originalError: <E>(obj: E) => E = core.originalInstance
|