Skip to content

Defined in header <fkYAML/exception.hpp>

fkyaml::exception::(constructor)

exception() = default; // (1)

explicit exception(const char* msg) noexcept; // (2)

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:

An error message.

See Also