Skip to main content

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
52%
Published
2 months ago (0.0.2)
function Err.from
from(e: unknown): Err<Error>

Converts any unknown value into an Error object.

This function handles two cases uniquely:

  1. If the input is already an Error, it's returned as-is.
  2. If the input is a non-null object, it's stringified and wrapped in an Error.

For all other types, the input is coerced to a string and wrapped in an Error.

Parameters

e: unknown
  • The value to convert into an Error.

Return Type

An Error object.

Add Package

deno add @trav/result

Import symbol

import { Err } from "@trav/result";
const { from } = Err;

Add Package

npx jsr add @trav/result

Import symbol

import { Err } from "@trav/result";
const { from } = Err;

Add Package

yarn dlx jsr add @trav/result

Import symbol

import { Err } from "@trav/result";
const { from } = Err;

Add Package

pnpm dlx jsr add @trav/result

Import symbol

import { Err } from "@trav/result";
const { from } = Err;

Add Package

bunx jsr add @trav/result

Import symbol

import { Err } from "@trav/result";
const { from } = Err;