> Catch JSON parse errors

@param  {Buffer} `val`
@return {String|Array|Error}
499106
function tryParse (val) {
  var res = null
  try {
    res = JSON.parse(val.toString())
  } catch (err) {
    res = err
  }
  return res
}
323789
function(data, callback) {
    var json
    try {
        json = JSON.parse(data)
    } catch (exc) {
        return callback(exc)
    }
    callback(null, json)
}
104310
function removeErrorRecovery (fn) {
    var parseFn = String(fn);
    try {
        var JSONSelect = require("JSONSelect");
        var Reflect = require("reflect");
        var ast = Reflect.parse(parseFn);

        var labeled = JSONSelect.match(':has(:root > .label > .name:val("_handle_error"))', ast);
        labeled[0].body.consequent.body = [labeled[0].body.consequent.body[0], labeled[0].body.consequent.body[1]];

        return Reflect.stringify(ast).replace(/_handle_error:\s?/,"").replace(/\\\\n/g,"\\n");
    } catch (e) {
        return parseFn;
    }
}
107418
function ParseError(msg) {
  this.name = 'ParseError';
  this.message = msg;
  if (Error.captureStackTrace) {
    Error.captureStackTrace(this, ParseError);
  }
}
482004
function regexify(val) {
  if (!val) return new RegExp;
  if (Array.isArray(val)) val = val.join("|");
  if (isString(val)) return new RegExp(val || "");
  if (isRegExp(val)) return val;
  throw new TypeError("illegal type for regexify");
}
1125597
function ParseError(message, start, end, next) {
	this.message = message;
	this.start = start;
	this.end = end;
	this.next = next;
}
1066991
public static function json($val, $strict = true): bool
    {
        if (!$val || (!\is_string($val) && !\method_exists($val, '__toString'))) {
            return false;
        }

        $val = (string)$val;

        // must start with: { OR [
        if ($strict && '[' !== $val[0] && '{' !== $val[0]) {
            return false;
        }

        \json_decode($val);

        return \json_last_error() === \JSON_ERROR_NONE;
    }
914501
def error_catch(f):
    """"""
    @wraps(f)
    def wrapper(*args, **kw):
        instance = args[0]
        try:
            result = f(*args, **kw)
            if isinstance(result, tuple):
                return jsonify(result[0]), result[1]
            else:
                return jsonify(result), 200
        except Exception as e:
            ret_dict = instance._create_ret_object(instance.FAILURE, None,
                                                   True,
                                                   instance.UNKNOWN_ERROR)
            log_dict = deepcopy(ret_dict)
            log_dict['error']['cause'] = e.message
            log_dict['error']['exception'] = str(e)
            log_dict['error']['ex'] = traceback.format_exc()
            instance.logger.error("Uncaught Exception Thrown", log_dict)
            return jsonify(ret_dict), 500
    return wrapper
20063
function _parseAttr(val, isClick) {
        try {
            if (isClick) {
                /*jshint evil: true */
                var fn = Function(val);

                return fn ? fn() : {};
            }

            return JSON.parse(val);
        } catch (err) {
            return undefined;
        }
    }
1270647
function parseError(error: Error | string | string[]): StackFrame[] {
  if (error == null) {
    throw new Error('You cannot pass a null object.')
  }
  if (typeof error === 'string') {
    return parseStack(error.split('\n'))
  }
  if (Array.isArray(error)) {
    return parseStack(error)
  }
  if (typeof error.stack === 'string') {
    return parseStack(error.stack.split('\n'))
  }
  throw new Error('The error you provided does not contain a stack trace.')
}
437316
function wrapError(spec, parsePayload) {
  return async function errorHandler(ctx, next) {
    try {
      await parsePayload(ctx, next);
    } catch (err) {
      captureError(ctx, 'type', err);
      if (spec.validate.continueOnError) {
        return await next();
      } else {
        return ctx.throw(err);
      }
    }
  };
}
242009
function findValueByPath(jsonData, path){
    var errorParts = false;
    path.split('.').forEach(function(part){
        if(!errorParts){
            jsonData = jsonData[part];
            if(!jsonData) errorParts = true;
        }
    });
    return errorParts ? 0 : parseFloat(jsonData);
}
1077321
function isError(val, prop) {
    if (!isValue(val) || !isObject(val))
        return false;
    var type = constant_1.toStr.call(val).toLowerCase();
    return type === '[object error]' || type === '[object domexception]' || !isEmpty(val[prop]);
}
224245
function getError(field, value) {
	// Check we actually got a string
	if (typeof value !== "string") {
		return errorInvalidParams(field + " must be a string");
	}
	// Check value is not empty
	if (!value.trim()) {
		return errorInvalidParams(field + " must not be empty");
	}
}
828796
function parseJson(name, type, value) {
    try {
        return typeof value  === 'string' ?
            JSON.parse(value) :
            value;
    } catch (e) {
        throwError(name, type, value);
    }
}
289828
function ( value ) {
		var tmp;

		if ( value === null || value === undefined ) {
			return undefined;
		}
		else if ( value === "true" ) {
			return true;
		}
		else if ( value === "false" ) {
			return false;
		}
		else if ( value === "null" ) {
			return null;
		}
		else if ( value === "undefined" ) {
			return undefined;
		}
		else if ( value === "" ) {
			return value;
		}
		else if ( !isNaN( tmp = Number( value ) ) ) {
			return tmp;
		}
		else if ( regex.json_wrap.test( value ) ) {
			return json.decode( value, true ) || value;
		}
		else {
			return value;
		}
	}
1023274
function serializeError(err) {
  var o = {};

  Object.getOwnPropertyNames(err).forEach(function (k) {
    o[k] = err[k];
  });

  return _.omit(o, ['stack', 'type', 'arguments']);
}