Hyperlinkv0.8.0-beta.28

Cause

Cause.annotationsconsteffect/Cause.ts:1894
<E>(self: Cause<E>): Context.Context<never>

Reads the merged annotations from all reasons in a Cause.

When to use

Use to read diagnostic metadata merged from the whole cause.

Gotchas

When multiple reasons contain the same annotation key, the value from the later reason wins.

Example (Reading merged annotations)

import { Cause, Context } from "effect"

class RequestId extends Context.Service<RequestId, string>()("RequestId") {}

const cause = Cause.annotate(
  Cause.fail("error"),
  Context.make(RequestId, "req-1")
)

console.log(Context.getOrUndefined(Cause.annotations(cause), RequestId)) // "req-1"
Source effect/Cause.ts:18941 lines
export const annotations: <E>(self: Cause<E>) => Context.Context<never> = effect.causeAnnotations