Hyperlinkv0.8.0-beta.28

Cause

Cause.reasonAnnotationsconsteffect/Cause.ts:1860
<E>(self: Reason<E>): Context.Context<never>

Reads the annotations from a single Reason as a Context.

When to use

Use when you need tracing metadata (e.g. StackTrace) from a specific reason rather than the whole cause.

Example (Reading reason annotations)

import { Cause, Context } from "effect"

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

const reason = Cause.makeFailReason("error")
const annotated = reason.annotate(Context.make(RequestId, "req-1"))

console.log(Context.getOrUndefined(Cause.reasonAnnotations(annotated), RequestId)) // "req-1"
annotationsannotations
Source effect/Cause.ts:18601 lines
export const reasonAnnotations: <E>(self: Reason<E>) => Context.Context<never> = effect.reasonAnnotations