Package: effect
Module: Cause
Attaches metadata to every reason in a Cause.
When to use
Use to attach diagnostic metadata to every reason in a cause.
Details
Annotations are stored as a Context on each reason and can be
retrieved later via reasonAnnotations or annotations.
The runtime uses this to attach stack traces and spans.
Cause.{ overwrite: true } to
replace them.Example (Annotating a cause)
import { Cause, Context } from "effect"
class RequestId extends Context.Service<RequestId, string>()("RequestId") {}
const cause = Cause.fail("error")
const annotated = Cause.annotate(cause, Context.make(RequestId, "req-1"))
console.log(Context.getOrUndefined(Cause.annotations(annotated), RequestId)) // "req-1"
See
annotations for reading merged annotations from a causereasonAnnotations for reading annotations from a single reasonSignature
declare const annotate: { (annotations: Context.Context<never>, options?: { readonly overwrite?: boolean | undefined; }): <E>(self: Cause<E>) => Cause<E>; <E>(self: Cause<E>, annotations: Context.Context<never>, options?: { readonly overwrite?: boolean | undefined; }): Cause<E>; }
Since v4.0.0