xtd 0.2.0
Loading...
Searching...
No Matches
format_exception.cpp

Show how to use format xtd::format class with exceptions.

#include <xtd/system_exception>
#include <xtd/argument_out_of_range_exception>
#include <xtd/ustring>
using namespace std;
using namespace xtd;
auto main()->int {
cout << ustring::format("{}", exception()) << endl;
cout << ustring::format("{}", invalid_argument("Invalid argument")) << endl;
cout << ustring::format("{}", system_exception("System exception")) << endl;
cout << ustring::format("{}", argument_out_of_range_exception("Argument out of range exception")) << endl;
}
// This code produces the following output :
//
// exception: std::exception
// exception: Invalid argument
// xtd::system_exception : System exception
// at main [0x00005620] in /Users/gammasoft71/Projects/xtd/build/xtd.examples/xtd.core.examples/format/format_exception/Debug/format_exception:line 0
// xtd::argument_out_of_range_exception : Argument out of range exception
// at main [0x00005620] in /Users/gammasoft71/Projects/xtd/build/xtd.examples/xtd.core.examples/format/format_exception/Debug/format_exception:line 0
The exception that is thrown when one of the arguments provided to a method is out of range.
Definition argument_out_of_range_exception.h:20
Defines the base class for predefined exceptions in the xtd namespace.
Definition system_exception.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10