fix bug in 'attempt' snippet
This commit is contained in:
@ -7,7 +7,7 @@ Use a `try... catch` block to return either the result of the function or an app
|
|||||||
```js
|
```js
|
||||||
const attempt = (fn, ...args) => {
|
const attempt = (fn, ...args) => {
|
||||||
try {
|
try {
|
||||||
return fn(args);
|
return fn(...args);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e instanceof Error ? e : new Error(e);
|
return e instanceof Error ? e : new Error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user