Hyperlinkv0.8.0-beta.28

ErrorReporter

ErrorReporter.attributestypeeffect/ErrorReporter.ts:473
"~effect/ErrorReporter/attributes"

Defines the string property key used to attach extra key/value metadata to an object error report.

When to use

Use to type the property key that attaches metadata to object error reports.

Details

Reporters receive these attributes alongside the error, making it easy to include contextual information such as user IDs, request IDs, or other domain-specific debugging data.

annotations
export type attributes = "~effect/ErrorReporter/attributes"

/**
 * Defines the runtime property key used to attach extra key/value metadata to an object
 * error report.
 *
 * **When to use**
 *
 * Use to attach domain metadata to object errors so reporter callbacks receive
 * it with the reported failure.
 *
 * **Details**
 *
 * Set `error[ErrorReporter.attributes]` to a record of metadata that should be
 * forwarded to reporters alongside the error.
 *
 * **Example** (Setting error attributes)
 *
 * ```ts
 * import { Data, ErrorReporter } from "effect"
 *
 * class PaymentError extends Data.TaggedError("PaymentError")<{
 *   readonly orderId: string
 * }> {
 *   readonly [ErrorReporter.attributes] = {
 *     orderId: this.orderId
 *   }
 * }
 * ```
 *
 * @see {@link ignore} for suppressing reports for expected object errors
 * @see {@link severity} for overriding reporter severity
 * @see {@link getAttributes} for reading the metadata stored under this key
 * @see {@link Reportable} for the annotation contract recognized on object
 * errors
 *
 * @category annotations
 * @since 4.0.0
 */
export const attributes: attributes = "~effect/ErrorReporter/attributes"
Referenced by 2 symbols