1.0.0 • Published 11 months ago

@dominikrusso/error v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@dominikrusso/error

This package provides sTry and aTry, functions that transform synchronous and asynchronous functions that throw or reject into functions that return their original return type or an error. isError can then be used to check if T | Error is an error.

import { sTry, isError } from "@dominikrusso/error";

const result = sTry(() => functionThatMightThrow(42));
//    ^ T | Error
if (isError(result)) {
    handleTheError(result)
    //             ^ Error
    process.exit(1);
}
console.log(result);
//          ^ T
1.0.0

11 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago