Skip to content

devlzcode/errd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published