FixedReport
is an error-type with a fixed-size stack-allocated buffer, containing an error string denoting the cause of the error from the error type of a Result<T, E>
.
The error-string stored in the report is truncated (and contains a message to signify truncation) if its given string is longer than stx::kReportReserveSize
.
- When the error types don't contain the string description of the errors themselves and the description strings are not
static
- When the string-description is not known at compile-time
Constructing a FixedReport
for your error type
FixedReport
s are automatically constructed for uint8_t
, uint16_t
, uint32_t
,int8_t
, int16_t
, int32_t
, string
, string_view
, and pointers, as the error strings are not known at compile-time and neither are the types containing a description of the error.
NOTE: If the error type already provides an error message or the needed error-message for the type is a static
duration value and known at compile, you can use SpanReport
instead which just forwards a reference to the error string.
Defining for your error type
struct Error {
int error;
void format_into(const char*, size_t size) const noexcept;
};
char buffer[64];
err.format_into(buffer, 64);
};
Exception-safety
Ensure to not throw exceptions.