Skip to main content
The Deno 2 Release Candidate is here
Learn more

try

try run await a function , else console.error(error)

export in your deps.js

export {default as _try} from 'https://deno.land/x/try@0.0.1/lib/index.js'

source code

export default (func, args...)=>
  try
    return await func(...args)
  catch err
    console.error(err)

use example

coffeescript version

import _try from './index.js'

test = (a, b, c)=>
  console.log "args", a, b ,c
  throw new Error('error')

_try test, 1, 2, 3

javascript version

// Generated by CoffeeScript 2.5.1
var test;

import _try from './index.js';

test = (a, b, c) => {
  console.log("args", a, b, c);
  throw new Error('error');
};

_try(test, 1, 2, 3);

//# sourceMappingURL=index_test.js.map