Handles parser internal errors
@param  {Object} spec         [description]
@param  {function} parsePayload [description]
@return {async function}              [description]
@api private
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);
      }
    }
  };
}
75512
function wrapParsePromise(promise, parsePromise) {
      ['_rejected', '_rejectedCallbacks', '_resolved', '_resolvedCallbacks', '_result', 'reject', 'resolve']
        .forEach(function (prop) {
          promise[prop] = parsePromise[prop];
        });

      ['_continueWith', '_thenRunCallbacks', 'always', 'done', 'fail'].forEach(function (method) {
        promise[method] = wrap(parsePromise[method]);
      });

      ['then', 'catch'].forEach(function (method) {
        var func = promise[method];
        promise[method] = function wrappedAngularPromise() {
          var args = Array.prototype.slice.call(arguments, 0);
          var promise = func.apply(this, args);
          wrapParsePromise(promise, parsePromise);
          return promise;
        };
      });

      return promise;
    }
1123737
function parseResource (err, responseSpec, next) {
      var resource = responseSpec ? responseSpec.body : undefined;
      this.invokeNext(err, resource, next);
    }
1175903
private JsonNode processErrorResponse(final JsonNode resp) {
        String errorMessage = resp.get("error").asText();
        if (resp.has("stack")) {
            errorMessage += "\n" + resp.get("stack").asText();
        }

        throw new JsiiException(errorMessage);
    }
874560
function parse(code, done) {
  var ast, err, jsonStyle = {}, log = []

  // css parse
  ast = css.parse(code, {silent: true})

  // catch syntax error
  if (ast.stylesheet.parsingErrors && ast.stylesheet.parsingErrors.length) {
    err = ast.stylesheet.parsingErrors
    err.forEach(function (error) {
      log.push({line: error.line, column: error.column, reason: error.toString().replace('Error', 'ERROR')})
    })
  }

  // walk all
  /* istanbul ignore else */
  if (ast && ast.type === 'stylesheet' && ast.stylesheet &&
      ast.stylesheet.rules && ast.stylesheet.rules.length) {
    ast.stylesheet.rules.forEach(function (rule) {
      var type = rule.type
      var ruleResult = {}
      var ruleLog = []

      if (type === 'rule') {
        if (rule.declarations && rule.declarations.length) {
          // transition shorthand parsing
          var CHUNK_REGEXP = /^(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?\s*(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?$/
          for (var i = 0; i < rule.declarations.length; i++) {
            var declaration = rule.declarations[i]
            if (declaration.property === 'transition') {
              var match = declaration.value.match(CHUNK_REGEXP)
              /* istanbul ignore else */
              if (match) {
                match[1] && rule.declarations.push({type: 'declaration', property: 'transition-property', value: match[1], position: declaration.position})
                match[2] && rule.declarations.push({type: 'declaration', property: 'transition-duration', value: match[2], position: declaration.position})
                match[3] && rule.declarations.push({type: 'declaration', property: 'transition-timing-function', value: match[3], position: declaration.position})
                match[4] && rule.declarations.push({type: 'declaration', property: 'transition-delay', value: match[4], position: declaration.position})
                rule.declarations.splice(i, 1)
                break
              }
            }
          }

          rule.declarations.forEach(function (declaration) {
            var subType = declaration.type
            var name, value, line, column, subResult, camelCasedName

            /* istanbul ignore if */
            if (subType !== 'declaration') {
              return
            }

            name = declaration.property
            value = declaration.value

            // validate declarations and collect them to result
            camelCasedName = util.hyphenedToCamelCase(name)
            subResult = validateItem(camelCasedName, value)

            /* istanbul ignore else */
            if (typeof subResult.value === 'number' || typeof subResult.value === 'string') {
              ruleResult[camelCasedName] = subResult.value
            }
            if (subResult.log) {
              subResult.log.line = declaration.position.start.line
              subResult.log.column = declaration.position.start.column
              ruleLog.push(subResult.log)
            }
          })

          rule.selectors.forEach(function (selector) {
            if (selector.match(/^\.[A-Za-z0-9_\-:]+$/)) {
              var className = selector.slice(1)

              // handle pseudo class
              var pseudoIndex = className.indexOf(':')
              if (pseudoIndex > -1) {
                var pseudoCls = className.slice(pseudoIndex)
                className = className.slice(0, pseudoIndex)
                var pseudoRuleResult = {}
                Object.keys(ruleResult).forEach(function (prop) {
                  pseudoRuleResult[prop + pseudoCls] = ruleResult[prop]
                })
                ruleResult = pseudoRuleResult
              }

              // merge style
              Object.keys(ruleResult).forEach(function (prop) {
                if (prop.indexOf('transition') === 0) { // handle transition
                  var realProp = prop.replace('transition', '')
                  realProp = realProp[0].toLowerCase() + realProp.slice(1)
                  jsonStyle['@TRANSITION'] = jsonStyle['@TRANSITION'] || {}
                  jsonStyle['@TRANSITION'][className] = jsonStyle['@TRANSITION'][className] || {}
                  jsonStyle['@TRANSITION'][className][realProp] = ruleResult[prop]
                }
                else {
                  jsonStyle[className] = jsonStyle[className] || {}
                  jsonStyle[className][prop] = ruleResult[prop]
                }
              })
            }
            else {
              log.push({
                line: rule.position.start.line,
                column: rule.position.start.column,
                reason: 'ERROR: Selector `' + selector + '` is not supported. Jud only support single-classname selector'
              })
            }
          })
          log = log.concat(ruleLog)
        }
      }
      /* istanbul ignore else */
      else if (type === 'font-face') {
        /* istanbul ignore else */
        if (rule.declarations && rule.declarations.length) {
          rule.declarations.forEach(function (declaration) {
            /* istanbul ignore if */
            if (declaration.type !== 'declaration') {
              return
            }
            var name = util.hyphenedToCamelCase(declaration.property)
            var value = declaration.value
            if (name === 'fontFamily' && '\"\''.indexOf(value[0]) > -1) { // FIXME: delete leading and trailing quotes
              value = value.slice(1, value.length - 1)
            }
            ruleResult[name] = value
          })
          if (!jsonStyle['@FONT-FACE']) {
            jsonStyle['@FONT-FACE'] = []
          }
          jsonStyle['@FONT-FACE'].push(ruleResult)
        }
      }
    })
  }

  done(err, {jsonStyle: jsonStyle, log: log})
}
1195910
function(sections, pathToSpec) {
    var deferred = Q.defer();

    // Parsing spec with JSdom
    jsdom.env(
        'http://127.0.0.1:' + global.opts.core.server.port + pathToSpec + '?internal=true',
        ['http://127.0.0.1:' + global.opts.core.server.port + '/source/assets/js/modules/sectionsParser.js'],
        function (err, window) {
            if (err) {
                deferred.reject({
                    err: err,
                    msg: 'JSDOM error'
                });
                return;
            }

            var output = {};

            var SourceGetSections = window.SourceGetSections;

            var parser = new SourceGetSections();
            var allContents = parser.getSpecFull();

            if (sections) {
                output = parser.getSpecFull(sections);
            } else {
                output = allContents;
            }

            if (output) {
                deferred.resolve({
                    output: output,
                    allContents: allContents
                });
            } else {
                deferred.reject({
                    msg: 'Requested sections HTML not found'
                });
            }
        }
    );

    return deferred.promise;
}
610594
function parseResult(text, callback) {
  var errors = [], i = 0, l, errBlock, match, match2, lines;

  text = text.replace(/\r/g, '');
  lines = text.split('\n');

  match = skippingRegex.exec(lines[i]);
  if (match) {
    i++;
  }

  match = successRegex.exec(lines[i]);
  if (match) {
    callback(null, createParseSuccessObj(match));
    return;
  }

  for (l = lines.length; i < l; i++) {
    match = fileRegex.exec(lines[i]);
    if (match) {
      match2 = errorRegex.exec(lines[++i]);
      errBlock = createFailObj(match);
      for (var j = i; match2 && j < lines.length;) {
        errBlock.errors.push(createErrorObj(match2));
        match2 = errorRegex.exec(lines[++j]);
      }
      i = --j;
      errors.push(errBlock);
    } else {
      match = abstractRegex.exec(lines[i]);
      if (match) {
        callback(createErrorGJSLintFailed(match, errors));
        return;
      }
    }
  }
  callback(createParseErrorUnknown(lines));

}
396292
function parseError(code, offset) {
    var position = now()

    position.column += offset
    position.offset += offset

    handleWarning.call(warningContext, MESSAGES[code], position, code)
  }
815865
function parse(doc) {
    var file = vfile(doc)
    var Parser

    freeze()
    Parser = processor.Parser
    assertParser('parse', Parser)

    if (newable(Parser)) {
      return new Parser(String(file), file).parse()
    }

    return Parser(String(file), file) // eslint-disable-line new-cap
  }
801500
def _process_async_error(self, resp_body, error_class):
        
        def _fmt_error(err):
            # Remove the cumbersome Java-esque message
            details = err.get("details", "").replace("\n", " ")
            if not details:
                details = err.get("message", "")
            return "%s (%s)" % (details, err.get("code", ""))

        error = resp_body.get("error", "")
        if "failedItems" in error:
            # Multi-error response
            faults = error.get("failedItems", {}).get("faults", [])
            msgs = [_fmt_error(fault) for fault in faults]
            msg = "\n".join(msgs)
        else:
            msg = _fmt_error(error)
        raise error_class(msg)
298025
def p_error(p):
    

    if p is None:
        raise MOFParseError(msg='Unexpected end of file')

    msg = p.lexer.last_msg
    p.lexer.last_msg = None
    raise MOFParseError(parser_token=p, msg=msg)
10887
async function parseReport() { // eslint-disable-line no-unused-vars
  try {
    const coverage = await promises.readFile('lcov.info', 'utf8');
    const report = Report.fromCoverage(coverage);
    console.log(`The coverage report contains ${report.records.length} records:`);
    console.log(report.toJSON());
  }

  catch (error) {
    console.log(`An error occurred: ${error.message}`);
  }
}
497689
function Parser (customKeywordSpec) {
    var keywordSpec = customKeywordSpec || {
        _: [0],
        gettext: [0],
        ngettext: [0, 1]
    };
    var openings = ['<%', '{\\*', '{{'];
    var closures = ['%>', '\\*}', '}}'];

    if (typeof keywordSpec !== 'object') {
        throw 'Invalid keyword spec';
    }

    this.keywordSpec = keywordSpec;
    this.expressionPattern = new RegExp([
        '(?:' + openings.join('[=-]|') + '[=-]) *',
        '(' + Object.keys(keywordSpec).map(escapeRegExp).join('|') + ')',
        '\\(',
        '([\\s\\S]*?)',
        '\\)',
        ' *(?:' + closures.join('|') + ')'
    ].join(''), 'g');
}
281463
function pathmap(path, spec, callback) {
  return spec.replace(regexp, function(match, replace, count, token) {
    var pattern;
    if (pattern = pathmap.patterns[token]) {
      return pattern.call(path, replace, count, callback);
    } else {
      throw new Error(
        'Unknown pathmap specifier ' + match + ' in "' + spec + '"');
    }
  });
}
565456
function makeJSONBodyParser(spec) {
  const opts = spec.validate.jsonOptions || {};
  if (typeof opts.limit === 'undefined') {
    opts.limit = spec.validate.maxBody;
  }

  return async function parseJSONPayload(ctx, next) {
    if (!ctx.request.is('json')) {
      return ctx.throw(400, 'expected json');
    }
    ctx.request.body = ctx.request.body || await parse.json(ctx, opts);
    await next();
  };
}
529775
function _parserPhantomJS(error){
		// start parse the error stack string
		var lines	= error.stack.split("\n").slice(1);
		var stacktrace	= [];
		lines.forEach(function(line){
			if( line.match(/\(native\)$/) ){
				var matches	= line.match(/^\s*at (.+) \(native\)/);
				stacktrace.push(new Stacktrace.Frame({
					fct	: matches[1],
					url	: 'native',
					line	: 1,
					column	: 1
				}));
			}else if( line.match(/\)$/) ){
				var matches	= line.match(/^\s*at (.+) \((.+):(\d+)\)/);
				stacktrace.push(new Stacktrace.Frame({
					fct	: matches[1],
					url	: matches[2],
					line	: parseInt(matches[3], 10),
					column	: 1
				}));
			}else{
				var matches	= line.match(/^\s*at (.+):(\d+)/);
				stacktrace.push(new Stacktrace.Frame({
					url	: matches[1],
					fct	: '<anonymous>',
					line	: parseInt(matches[2], 10),
					column	: 1
				}));
			}
		});
		return stacktrace;
	}
361894
function parseErrorState(packet, state) {
  let states = 0;

  state.forEach((s) => {
    if (s === 1) {
      states += 1;
    }
  });

  if (states >= 6) {
    packet.errorStatus = true; // eslint-disable-line no-param-reassign
  }
}