method ErrorFactory.invalidJson
ErrorFactory.invalidJson(
filePath: string,
parseError: string,
): NagareError

Create an invalid JSON error

Examples

Example 1

try {
  JSON.parse(content);
} catch (e) {
  throw ErrorFactory.invalidJson("./config.json", e.message);
}

Parameters

filePath: string
  • Path to the JSON file with syntax error
parseError: string
  • The JSON parse error message

Return Type

Error with JSON debugging suggestions

Usage

import { ErrorFactory } from ".";