npm.io
2.0.1 • Published 1 year ago

@arcscord/error

Licence
MIT
Version
2.0.1
Deps
0
Size
18 kB
Vulns
0
Weekly
24

@arcscord/error

A error handling package, inspired of golang error handling.

Exemple

import { error, ok, Result } from "@arscord/error";

function foo(num: number): Result<boolean, Error> {
  if (num <= 0) {
    return error(new Error("Get negative number"));
  }
  return ok(num % 2 === 0);
}

const [err, isFoo] = foo(3);
if (err) {
  console.error(err);
}
else {
  console.log(isFoo);
}

Made by Arcoz with

Keywords