Skip to main content
Module

x/result_js/mod.ts>unwrapErr

Minimum result type port of Rust
Latest
function unwrapErr
import { unwrapErr } from "https://deno.land/x/result_js@2.0.0/mod.ts";

Returns the contained Err value.

Examples

Example 1

import { Err } from "https://deno.land/x/result_js/spec.ts";
import { unwrapErr } from "https://deno.land/x/result_js/operators/extract.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(unwrapErr(Err(0)), 0);

Example 2

import { Ok } from "https://deno.land/x/result_js/spec.ts";
import { unwrapErr } from "https://deno.land/x/result_js/operators/extract.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";

assertThrows(() => unwrapErr(Ok(0)));

Parameters

result: Result<unknown, E>