ReportableInterface that object errors can implement to control reporting behavior.
When to use
Use as the annotation contract for object errors that customize how error reporting handles them.
Details
All three annotation properties are optional: [ErrorReporter.ignore]
prevents reporting when set to true, [ErrorReporter.severity] overrides
the default "Info" severity, and [ErrorReporter.attributes] adds extra
key/value pairs forwarded to reporters. The global Error interface is
augmented with Reportable, so these properties are available on Error
instances at the type level.
export interface Reportable {
readonly [const ignore: ignoreDefines the string property key used to mark an object error as ignored by error
reporting.
When to use
Use to type the property key that suppresses reporting for expected object
errors.
Details
Set this property to true on an error class or object error to prevent it
from being forwarded to reporters. This is useful for expected failures such
as HTTP 404 responses.
Defines the runtime property key used to mark an object error as ignored by error
reporting.
When to use
Use to suppress reporting for expected object errors, such as HTTP 404
responses.
Details
Set error[ErrorReporter.ignore] to true to prevent the error from being
forwarded to reporters. This is useful for expected failures such as HTTP 404
responses.
Example (Marking errors as ignored)
import { Data, ErrorReporter } from "effect"
class NotFoundError extends Data.TaggedError("NotFoundError")<{}> {
readonly [ErrorReporter.ignore] = true
}
ignore]?: boolean
readonly [const severity: severityDefines the string property key used to override the severity level of an object error.
When to use
Use to type the property key that overrides the reporting severity for object
errors.
Details
When set to a valid LogLevel.Severity, the reporter callback receives this
value as severity. Missing or invalid values fall back to "Info".
Defines the runtime property key used to override the severity level of an object error.
When to use
Use to annotate object errors with the severity reporter callbacks should
receive.
Details
Set error[ErrorReporter.severity] to a valid LogLevel.Severity value.
Missing or invalid values fall back to "Info".
Example (Setting error severity annotations)
import { Data, ErrorReporter } from "effect"
class DeprecationWarning extends Data.TaggedError("DeprecationWarning")<{}> {
readonly [ErrorReporter.severity] = "Warn" as const
}
severity]?: type Severity = "Fatal" | "Error" | "Warn" | "Info" | "Debug" | "Trace"Log levels that represent actual message severities, excluding the All and
None sentinel levels.
When to use
Use when typing emitted log message severities, such as explicit log calls,
current log level references, or error-report severity annotations, where
All and None are not valid values.
Severity
readonly [const attributes: attributesDefines 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.
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)
import { Data, ErrorReporter } from "effect"
class PaymentError extends Data.TaggedError("PaymentError")<{
readonly orderId: string
}> {
readonly [ErrorReporter.attributes] = {
orderId: this.orderId
}
}
attributes]?: type ReadonlyRecord<in out K extends string | symbol, out A> = { readonly [P in K]: A; }Represents a readonly record with keys of type K and values of type A.
This is the foundational type for immutable key-value mappings in Effect.
Example (Defining a readonly record type)
import type { Record } from "effect"
// Creating a readonly record type
type UserRecord = Record.ReadonlyRecord<"name" | "age", string | number>
const user: UserRecord = {
name: "John",
age: 30
}
Namespace containing utility types for working with readonly records.
These types help with type-level operations on record keys and values.
Example (Using readonly record helper types)
import type { Record } from "effect"
// Using NonLiteralKey to convert literal keys to generic types
type GenericKey = Record.ReadonlyRecord.NonLiteralKey<"foo" | "bar"> // string
// Using IntersectKeys to find common keys between record types
type CommonKeys = Record.ReadonlyRecord.IntersectKeys<"a" | "b", "b" | "c"> // "b"
ReadonlyRecord<string, unknown>
}