summaryrefslogtreecommitdiff
path: root/node_modules/json-parse-helpfulerror/index.js~
blob: 6e11c92f22ccf44f12449c4547191e9ed6886fa1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';

var jju = require('jju');

function parse(text, reviver) {
  try {
    return JSON.parse(text, reviver);
  } catch(err) {
    // we expect this throw with a more informative message
    jju.parse(text, {
      mode: 'json',
      reviver: reviver
    });

    // if it didn't throw, re-throw the original error
    throw err;
  }
}

module.exports = parse;