1.0.0 • Published 1 year ago

errd v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

errd

Collection of error handling utilities for JavaScript and TypeScript.

Usage

import { Ok /* Err, type Result */ } from "errd/result";
const result = Ok(42);
if (result.isOk()) console.log(result.unwrap());
else console.error(result.unwrapErr());
import { Some /* None, type Option */ } from "errd/option";
const maybe = Some(1);
if (maybe.isSome()) console.log(result.unwrap());
else console.log("none");
import { Try } from "errd/try";
const [err, result] = Try.from(() => 42);
const [err2, result2] = Try.fromAsync(() => fetch("https://..."));
import {
  normalizeError /* isError, isErrnoException, isErrorLike, */,
} from "errd/util";
try {
  throw new Error("oops");
} catch (error) {
  normalized = normalizeError(error);
  console.error(error);
}
1.0.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago