Skip to content

Allow reporting locations of semantic errors #57

@astralarya

Description

@astralarya

It would be nice if there were a mechanism for reporting the locations of semantic errors (e.g. incorrect value type). It looks like the functionality is almost there with Value::getOffsetStart(). Perhaps something like:

void Reader::pushError(const Value& value, std::string msg);

which would use the Value offset and Reader::begin_ to calculate a Reader::Location and push_back a Reader::ErrorInfo onto Reader::errors_. The error could then be printed with a call to Reader::getFormattedErrorMessages(). Perhaps there could be a:

void Reader::pushError(const Value& value, std::string msg, const Value& extra);

that also initializes Reader::ErrorInfo::extra_.

Of course then it would be nice to have a function

bool Reader::good() const;

to return !Reader::errors_.size().

Soooo, I guess I basically could implement this right now....lol. Expect a pull request shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions