alexreardon / tiny-invariant

A tiny invariant function

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CusomError

fakkio opened this issue · comments

hi,

it would be nice if you can pass, as second parameter, a custom error to be thrown.

e.g:

invariant(currentUser.roles.includes("admin"), new ForbiddenError("You are not authorized to view this resource"));

Fabio.

This would be cool and I have needed this too