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 exception with an overloaded constructor.

Overload (1)

exception() = default; // (1)

Constructs an exception object without an error message.

Example
#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:


Overloads (2)

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

Constructs an exception with a given error message.
The given error message can be retrieved by calling exception::what() function.

Parameters

msg [in]
An error message for the exception. If nullptr is given, the resulting error message will be empty.
Example
#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