(u: unknown): booleanReads the runtime error-reporting marker from an unknown error value.
When to use
Use to read whether an unknown error value should be treated as already reported by the default main runner.
Details
Returns a boolean [Runtime.errorReported] property when it is present on an
object. Otherwise returns true, so failures are logged by default.
Gotchas
Non-object values, missing markers, and non-boolean marker values all return
true.
export const const getErrorReported: (
u: unknown
) => boolean
Reads the runtime error-reporting marker from an unknown error value.
When to use
Use to read whether an unknown error value should be treated as already
reported by the default main runner.
Details
Returns a boolean [Runtime.errorReported] property when it is present on an
object. Otherwise returns true, so failures are logged by default.
Gotchas
Non-object values, missing markers, and non-boolean marker values all return
true.
getErrorReported = (u: unknownu: unknown): boolean => {
if (typeof u: unknownu === "object" && u: object | nullu !== null && const errorReported: errorReportedType-level key for the Runtime.errorReported marker.
When to use
Use to type properties keyed by Runtime.errorReported on custom error
values.
Defines the runtime marker that controls default runMain error logging for an error.
When to use
Use when you need error classes reported by application code to avoid being
logged again by the default main runner.
Details
Set [Runtime.errorReported] to false on an error object to suppress the
runtime log because the error has already been reported. Omitted or
non-boolean values are treated as true, so failures are logged by default.
Gotchas
This marker controls only automatic error logging. It does not change the
failure Cause or the process exit code.
makeRunMain reads the marker from Cause.squash(cause), so for causes
with multiple failures, the squashed error determines whether default logging
is suppressed.
Example (Suppressing error reporting)
import { Data, Effect, Runtime } from "effect"
import { NodeRuntime } from "@effect/platform-node"
class MyError extends Data.TaggedError("MyError") {
readonly [Runtime.errorReported] = false
}
// If the program fails with MyError, the process will exit with code 1 but
// no error will be logged.
NodeRuntime.runMain(Effect.fail(new MyError()))
errorReported in u: objectu) {
const const isReported: unknownisReported = u: object &
Record<"~effect/Runtime/errorReported", unknown>
u[const errorReported: errorReportedType-level key for the Runtime.errorReported marker.
When to use
Use to type properties keyed by Runtime.errorReported on custom error
values.
Defines the runtime marker that controls default runMain error logging for an error.
When to use
Use when you need error classes reported by application code to avoid being
logged again by the default main runner.
Details
Set [Runtime.errorReported] to false on an error object to suppress the
runtime log because the error has already been reported. Omitted or
non-boolean values are treated as true, so failures are logged by default.
Gotchas
This marker controls only automatic error logging. It does not change the
failure Cause or the process exit code.
makeRunMain reads the marker from Cause.squash(cause), so for causes
with multiple failures, the squashed error determines whether default logging
is suppressed.
Example (Suppressing error reporting)
import { Data, Effect, Runtime } from "effect"
import { NodeRuntime } from "@effect/platform-node"
class MyError extends Data.TaggedError("MyError") {
readonly [Runtime.errorReported] = false
}
// If the program fails with MyError, the process will exit with code 1 but
// no error will be logged.
NodeRuntime.runMain(Effect.fail(new MyError()))
errorReported]
if (typeof const isReported: unknownisReported === "boolean") {
return const isReported: booleanisReported
}
}
return true
}