Skip to content

Throw json schema validator exception by default #170

Open
@Leon0402

Description

@Leon0402

Hi,

I noticed that the library by default just throws std::invalid_argument here

throw std::invalid_argument(std::string("At ") + ptr.to_string() + " of " + instance.dump() + " - " + message + "\n");
.

I don't want to catch std::invalid_argument. I know I can provide my own error handler, but it looks identical to the default one except that it throws a subclass of std::invalid_argument.
So I wonder if the lib itself could not just do that by default?

A second thing I wondered:

virtual void error(const json::json_pointer & /*ptr*/, const json & /*instance*/, const std::string & /*message*/) = 0;

Couldn't this member function made const and therefore every argument of validate made const too? This would allow to pass RValue to validate().

So validate(j, MyHandler {});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions