Defined in header <fkYAML/exception.hpp>
fkyaml::exception::(constructor)¶
Constructs an exception object.
You can specify an error message on constructing an object with an overloaded constructor.
Parameters¶
msg
[in]- An error message for the exception. If
nullptr
is given, the resulting error message will be empty.
Overload(1): create a default value
#include <iostream>
#include <fkYAML/node.hpp>
int main() {
try {
throw fkyaml::exception();
}
catch (const fkyaml::exception& e) {
std::cout << e.what() << std::endl;
}
return 0;
}
output:
Examples¶
Overload(2): create an object with an error message
#include <iostream>
#include <fkYAML/node.hpp>
int main() {
try {
throw fkyaml::exception("An error message.");
}
catch (const fkyaml::exception& e) {
std::cout << e.what() << std::endl;
}
return 0;
}
output: