class Error

Defined at line 44 of file ../../sdk/lib/c/dlfcn/dl/error.h

The dl::Error object is created to hold an error string. It's not created

at all if there's no error.

It's movable, but not copyable. For convenience it can be constructed with

printf-like arguments directly. Most often it's only move-constructed or

default-constructed. It's move-assignable only when in its initial state or

its moved-from state.

Once created, then the object must be "set" and then must be "taken" before

it's destroyed to avoid assertion failures.

It's set by a call to the Printf method, or by constructing with printf-like

arguments instead of default-constructing. It's an assertion failure to

call Printf on an object not in its default-constructed state. In that

state, it's an assertion failure to destroy the object without calling

Printf on it. It's an assertion failure to do a Printf call or construction

that produces no output (like Printf("%s", "")). Printf cannot fail, but

also will not crash if memory allocation fails; instead it will act as if

Printf("out of memory") had been called.

The object is "taken" by calling take_str() or take_c_str(). Both return a

pointer that is valid only for the lifetime of this dl::Error object. After

this, the object can only be destroyed or moved-from. It must be kept alive

as long as the string pointer is being used.

Public Methods

void Error (const char * format)

This has to be written twice as method and constructor because varargs, but

they will probably be folded by ICF.

Defined at line 14 of file ../../sdk/lib/c/dlfcn/dl/error.cc

void Printf (const char * format)

This must be called exactly once after default construction and before

anything else (except moving from or into the object).

Defined at line 21 of file ../../sdk/lib/c/dlfcn/dl/error.cc

void Printf (const char * format, va_list args)

Defined at line 28 of file ../../sdk/lib/c/dlfcn/dl/error.cc

void Error ()

Defined at line 46 of file ../../sdk/lib/c/dlfcn/dl/error.h

void Error (const Error & )

Defined at line 48 of file ../../sdk/lib/c/dlfcn/dl/error.h

void Error (Error && other)

Defined at line 50 of file ../../sdk/lib/c/dlfcn/dl/error.h

void Error (const char * format, va_list args)

Defined at line 54 of file ../../sdk/lib/c/dlfcn/dl/error.h

Error & operator= (const Error & )

Defined at line 56 of file ../../sdk/lib/c/dlfcn/dl/error.h

Error & operator= (Error && other)

Defined at line 58 of file ../../sdk/lib/c/dlfcn/dl/error.h

Error OutOfMemory ()

Construct an Error object specifically for an out-of-memory scenario. This

sets buffer

&

size values accordingly so that take_* methods will

recognize the allocation failure and return an appropriate error string.

Defined at line 77 of file ../../sdk/lib/c/dlfcn/dl/error.h

std::string_view take_str ()

This must be called exactly once after Printf has been called (or after

any non-default construction). The returned string is valid only for the

lifetime of this Error object. After this, the object can only be

destroyed, move-assigned (which also invalidates the string returned

here), or moved-from (which does not).

Defined at line 84 of file ../../sdk/lib/c/dlfcn/dl/error.h

const char * take_c_str ()

This is the same as take_str(), but with a NUL-terminated C string. One

X-or the other of take_str() and take_c_str() must be called exactly once.

Defined at line 101 of file ../../sdk/lib/c/dlfcn/dl/error.h

Error && take ()

This just returns this object as an rvalue like std::move, but it's an

assertion failure if this object is in default-constructed, moved-from, or

taken state. It must be set but not yet taken.

Defined at line 106 of file ../../sdk/lib/c/dlfcn/dl/error.h

void ~Error ()

Defined at line 119 of file ../../sdk/lib/c/dlfcn/dl/error.h

Friends

class StatefulError
class DiagnosticsReport