struct std.Error
Overview
This struct is used as a header to an error-describing buffer. More…
struct Error { // fields uint32_t m_size; std.Guid m_guid; uint32_t m_code; // properties string_t const property m_description; };
Detailed Documentation
This struct is used as a header to an error-describing buffer.
Often times error is completely described by std.Error
struct – for
example, errno
, NTSTATUS
or WinError
. However, you can store as
much information as necessary to fully describe your error. If extra bytes
of information are required, they should follow the std.Error
header.
Fields
uint32_t m_size
The full size of error-describing buffer. Should always be
>= sizeof(std.Error)
.
std.Guid m_guid
The GUID
of the error. It tells Jancy runtime how to interpret
m_code
and the extra bytes of data following std.Error
header.
uint32_t m_code
The numerical code of the error. The actual meaning of this code depends
on m_guid
field. It may be errno
, or NTSTATUS
, or some
user-defined code.
Properties
string_t const property m_description
Creates and returns human-readable description of the error.
Jancy also supports a special formatter $!
which if used inside
formatting literal expands into description of the last error:
printf($"cannot open file: $!\n");
The code above is equivalent to:
string_t s = std.getLastError ().m_description; printf($"cannot open file: $s\n");