Giter Site home page Giter Site logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
I'm not sure I understand - is the runtime crash you're talking about an 
uncaught
exception?

If so, this is the intended behavior! If you let an exception leak out of the 
main()
function without being caught, the program will terminate. In Visual Studio, it
should say something like "uncaught exception: YAML::RepresentationException" 
in the
debug window, I think.

If you want to access a node in a map without worrying about exceptions, use
`Node::FindValue`, which returns a pointer to the node instead of a reference.

    if(const YAML::Node *pName = doc.FindValue("name")) {
        std::string name;
        *pName >> name;
        std::cout << "Key 'name' exists, with value '" << name << "'\n";
    } else {
        std::cout << "Key 'name' doesn't exist\n";
    }

See http://code.google.com/p/yaml-cpp/wiki/HowToParseADocument for more info 
(look at
the section "Optional Keys".

Original comment by [email protected] on 15 Sep 2009 at 2:22

  • Added labels: ****
  • Removed labels: ****

from yaml-cpp.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
Yes the message is about an unhandled exception and in the commandline appears: 
"This
application has requested the Runtime to terminate it in an unusual way. Please
contact the application's support team for more information."

So this is a normal behaviour?

Original comment by [email protected] on 15 Sep 2009 at 2:56

  • Added labels: ****
  • Removed labels: ****

from yaml-cpp.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
BTW I noticed that the Line and Column info in the exception message doesn't 
match
well with the real place of the error.

Original comment by [email protected] on 15 Sep 2009 at 2:57

  • Added labels: ****
  • Removed labels: ****

from yaml-cpp.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
Yes, this is normal behavior. You should to catch and handle exceptions, if you 
can.
How else would you like yaml-cpp to tell you that the key doesn't exist?

Think about it this way: by calling

node["name"]

we must return a reference to a const Node (of the value corresponding to the 
key
"name"). If the key doesn't exist, what should we return? There are no null
references, so the function operator[] can't fulfill its contract, so it throws 
an
exception.

For the line/column info, it probably refers to the start of the map node that 
you're
inspecting. Since the key wasn't found, we can't give the line/column info of 
the key
that you *meant* to use (since we don't know!).

I'm going to mark this issue as "Invalid" since it's intended behavior.

Original comment by [email protected] on 15 Sep 2009 at 8:39

  • Changed state: Invalid
  • Added labels: ****
  • Removed labels: ****

from yaml-cpp.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
About the line/column info of the occurring error place: I tried to produce 
several
different errors and it never matched the right place. At best it found the 
right line.

Thanks for your help.

Original comment by [email protected] on 15 Sep 2009 at 8:53

  • Added labels: ****
  • Removed labels: ****

from yaml-cpp.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
Do you have an example of the line/column problem?

Original comment by [email protected] on 15 Sep 2009 at 9:31

  • Added labels: ****
  • Removed labels: ****

from yaml-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.