Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Return sensible errors when semicolons are detected #2

Open
@jarjee

Description

@jarjee

This is a pretty common mistake to make, and it's never valid to have a semicolon in ejson.

We can trap the case where a semicolon is found (in the wrong location), and then return a more sensible error message.

IE it could look something like this, if we can't get the numbers out more easily.

      const match = /Unexpected token \(([0-9]+):([0-9]+)\)/.exec(e.message);
      const line = Number(match[1]) - 1;
      const column = Number(match[2]) - 1;
      const char = input.split('\n')[line][column];

      if (char === ';') {
        throw new Error(`Unexpected semicolon at (${match[1]}:${match[2]})`);
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions