normal-error
v0.2.0
Published
normalized error and some utils
Downloads
5
Readme
normal-error
simple util to normalize a unknown
variable to error
try {
fn()
} catch (e) {
console.log(toNormalizedError(e))
}
to
auto catch and normalize error, return result or NormalizedError
const result = to(async () => 1)
if (isNormalizedError(result)) {
// ...
}
// promise
const result1 = to(Promise.resolve('test'))
tryCatch
auto catch and normalize error, return [result, NormalizedError]
const [result, err] = tryCatch(async () => 1)
if (isNormalizedError(result)) {
// ...
}
// promise
const [result1, err1] = tryCatch(Promise.resolve('test'))