Skip to content

operator>> writes to stderr #665

Closed
Closed
@wolframroesler

Description

@wolframroesler

Hi,

is it intentional that operator>> writes to stderr before throwing an exception in 1.8.3? IMHO it shouldn't do that - it's an unexpected side effect, and it messes up the application's error output. Not every bad input to the JSON parser is an error I want logged on stderr. No other JsonCpp function writes anything to stderr before throwing. Also, it didn't do that in 1.8.0. Also, it uses fprintf which it not really C++-like (which makes me hope it's just some forgotten debug output).

I suggest removing the fprintf(stderrr,...), or #ifdefing it out if you really need it.

Thanks

Wolfram

JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
  CharReaderBuilder b;
  JSONCPP_STRING errs;
  bool ok = parseFromStream(b, sin, &root, &errs);
  if (!ok) {
    fprintf(stderr,
            "Error from reader: %s",
            errs.c_str());

    throwRuntimeError(errs);
  }
  return sin;
}

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