Comments (6)
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.
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.
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.
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.
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.
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)
- Add more hits to the error "Error msg: bad conversion" HOT 1
- Inconsistency bug or a feature in 0.7.0 HOT 7
- Figuring out if a string will round-trip
- Cannot specify link libraries for target "yaml-cpp"
- Building robot_localization pkg error with yaml-cpp target not found HOT 1
- YAML Emitter using YAML::DoubleQuoted when emitted in a destructor of a staticly created struct/class
- Numbers are emitted wrongly under non-C locales. HOT 2
- Problems with absend symbols in static library on Windows HOT 5
- CMake: handle backward compatibility HOT 3
- Add example of emitting tags to documentation. HOT 2
- `YAML::Literal` does not work for `YAML::Binary` HOT 5
- How to import yaml-cpp to my project using yaml-cpp-config.cmake? HOT 1
- Floating-point numbers are uglified, a.k.a. write shortest floating-point representation with round-trip guarantee HOT 21
- Empty strings are silently replaced with 'null' now HOT 5
- Is the key of a node can be modified? HOT 1
- Parsing Binary value in Literal syntax resulting in extra newline character being added. HOT 2
- Example from tutorial crashes HOT 2
- .a works on many facility but error when compile on one of arm HOT 1
- seems yaml-cpp conan package does not support build_type=RelWithDebInfo properly.
- issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml-cpp.