Hyperlinkv0.8.0-beta.28

Cause

Cause.UnknownErrorinterfaceeffect/Cause.ts:1762
UnknownError

A wrapper for errors whose type is not statically known.

Details

Used when a thrown or rejected value is not represented by a more specific typed error. The original value is stored in the cause property inherited from Error. Implements YieldableError.

Example (Creating and checking an UnknownError)

import { Cause } from "effect"

const error = new Cause.UnknownError("original", "Something unknown")
console.log(error._tag)    // "UnknownError"
console.log(error.message) // "Something unknown"
errors
Source effect/Cause.ts:176223 lines
export interface UnknownError extends YieldableError {
  readonly [UnknownErrorTypeId]: typeof UnknownErrorTypeId
  readonly _tag: "UnknownError"
}

/**
 * Constructs an `UnknownError`. The first argument is the original
 * cause (stored in `Error.cause`); the second is an optional human-readable
 * message.
 *
 * **Example** (Creating an UnknownError)
 *
 * ```ts
 * import { Cause } from "effect"
 *
 * const error = new Cause.UnknownError({ raw: true }, "Unexpected value")
 * console.log(error.message) // "Unexpected value"
 * ```
 *
 * @category constructors
 * @since 4.0.0
 */
export const UnknownError: new(cause: unknown, message?: string) => UnknownError = effect.UnknownError
Referenced by 2 symbols