How to use the tryCatch function from ramda

Find comprehensive JavaScript ramda.tryCatch code examples handpicked from public code repositorys.

430
431
432
433
434
435
436
437
438
439
440
 * @param {*} ummJSON - CMR search response in UMM JSON format
 * @returns {Object[]} a possibly empty array of the `umm` properties of the
 *    `items` in the specified response object
 */
const transformUMMJSONResponse = R.pipe(
  R.tryCatch(JSON.parse, (_parseError, response) => { throw new Error(response) }),
  R.when(R.hasIn("items"), R.pipe(R.prop("items"), R.map(R.prop("umm")))),
);


/**
fork icon1
star icon0
watch icon0

4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
 * @param {Function} tryer The function that may throw.
 * @param {Function} catcher The function that will be evaluated if `tryer` throws.
 * @return {Function} A new function that will catch exceptions and send then to the catcher.
 * @example
 *
 *      R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true
 *      R.tryCatch(R.prop('x'), R.F)(null);      //=> false
 */
var tryCatch = _curry2(function _tryCatch(tryer, catcher) {
    return _arity(tryer.length, function () {
fork icon0
star icon0
watch icon0

+ 35 other calls in file

14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
 * @example
 *
 *      R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true
 *      R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched'
 *      R.tryCatch(R.times(R.identity), R.always([]))('s') // => []
 *      R.tryCatch(() => { throw 'this is not a valid value'}, (err, value)=>({error : err,  value }))('bar') // => {'error': 'this is not a valid value', 'value': 'bar'}
 */




var tryCatch =
fork icon0
star icon0
watch icon2

+ 15 other calls in file

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)