-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yaml-cpp crashed when loading a wrong format yaml file #701
Comments
I'm not good at English, so I may have misunderstood your comment.
This error is not handled inside yaml-cpp because it is a syntax error in the your YAML file. example: try {
YAML::Node rNode = YAML::LoadFile(“test.yaml”);
// using YAML node.
} catch(const YAML::ParserException& ex) {
std::cout << ex.what() << std::endl;
} see: yaml-cpp/include/yaml-cpp/node/parse.h Lines 40 to 46 in 4fb1c4b
|
@tt4g Thanks for your reply, you have totally understood what i am saying, there is no problem about catch the execption myself, just recommend to handle it in yaml-cpp to prevent to programe from crash. |
@tt4g is correct; this is working as intended. The library is designed for you to handle incorrectly formed YAML by catching |
When using
YAML::Node rNode = YAML::LoadFile(“test.yaml”)
terminal output log as below :
terminating with uncaught exception of type YAML::ParserException: yaml-cpp: error at line 14, column 15: illegal map value
test.yaml's content as below:
( sorry for that i can't make the file content indent correctly)
After checking the code, i found that the method
Scanner::ScanValue()
throw out a execption withthrow ParserException(INPUT.mark(), ErrorMsg::MAP_VALUE);
, but seems no code the handle this execptionQuestion :
YAML::Parser
can not parse or skiptest:henson
which has no black space after ":"The text was updated successfully, but these errors were encountered: