repl.txt (720B)
1 2 {{alias}}( fcn[, thisArg] ) 3 Wraps a function in a try/catch block. 4 5 If provided an asynchronous function, the returned function only traps 6 errors which occur during the current event loop tick. 7 8 If a function throws a literal, the literal is serialized as a string and 9 returned as an `Error` object. 10 11 Parameters 12 ---------- 13 fcn: Function 14 Function to wrap. 15 16 thisArg: any (optional) 17 Function context. 18 19 Returns 20 ------- 21 out: Function 22 Wrapped function. 23 24 Examples 25 -------- 26 > function fcn() { throw new Error( 'beep boop' ); }; 27 > var f = {{alias}}( fcn ); 28 > var out = f(); 29 > out.message 30 'beep boop' 31 32 See Also 33 -------- 34