[meta.reflection.exception] # 21 Metaprogramming library [[meta]](./#meta) ## 21.4 Reflection [[meta.reflection]](meta.reflection#exception) ### 21.4.4 Class exception [meta.reflection.exception] [🔗](#lib:exception) namespace std::meta {class exception : public std::exception {private: optional *what_*; // *exposition only* u8string *u8what_*; // *exposition only* info *from_*; // *exposition only* source_location *where_*; // *exposition only*public:consteval exception(u8string_view what, info from, source_location where = source_location::current()) noexcept; consteval exception(string_view what, info from, source_location where = source_location::current()) noexcept; exception(const exception&) = default; exception(exception&&) = default; exception& operator=(const exception&) = default; exception& operator=(exception&&) = default; constexpr const char* what() const noexcept override; consteval u8string_view u8what() const noexcept; consteval info from() const noexcept; consteval source_location where() const noexcept; };} [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3467) Reflection functions throw exceptions of type meta​::​exception to signal an error[.](#1.sentence-1) meta​::​exception is a consteval-only type[.](#1.sentence-2) [🔗](#lib:exception,constructor) `consteval exception(u8string_view what, info from, source_location where = source_location::current()) noexcept; ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3478) *Effects*: Initializes*u8what_* with what,*from_* with from, and*where_* with where[.](#2.sentence-1) If what can be represented in the ordinary literal encoding, initializes *what_* with what, transcoded from UTF-8 to the ordinary literal encoding[.](#2.sentence-2) Otherwise, *what_* is value-initialized[.](#2.sentence-3) [🔗](#lib:exception,constructor_) `consteval exception(string_view what, info from, source_location where = source_location::current()) noexcept; ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3496) *Constant When*: what designates a sequence of characters that can be encoded in UTF-8[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3501) *Effects*: Initializes*what_* with what,*u8what_* with what transcoded from the ordinary literal encoding to UTF-8,*from_* with from and*where_* with where[.](#4.sentence-1) [🔗](#lib:what,exception) `constexpr const char* what() const noexcept override; ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3517) *Constant When*: *what_*.has_value() is true[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3521) *Returns*: *what_*->c_str()[.](#6.sentence-1) [🔗](#lib:u8what,exception) `consteval u8string_view u8what() const noexcept; ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3531) *Returns*: *u8what_*[.](#7.sentence-1) [🔗](#lib:from,exception) `consteval info from() const noexcept; ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3541) *Returns*: *from_*[.](#8.sentence-1) [🔗](#lib:where,exception) `consteval source_location where() const noexcept; ` [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3551) *Returns*: *where_*[.](#9.sentence-1)