Error::Fmt( StrBuf *, int )
Format the text of an error into a StrBuf
, after applying
formatting.
Virtual? |
No |
|
Class |
||
Arguments |
|
a pointer to the |
|
formatting options |
|
Returns |
|
Notes
The result of Fmt()
is
suitable for displaying to an end user; this formatted text is what the
command line client displays when an error occurs.
If an error has no severity (E_EMPTY
), Fmt()
returns with no change to
the StrBuf
.
If the error has severity of info (E_INFO
), the
StrBuf
is formatted.
If the error has any higher severity, the StrBuf
argument
passed to Fmt()
is cleared and
then replaced with the formatted error.
The opts
argument is a flag or combination of flags defined
by the ErrorFmtOpts
enum. The default is
EF_NEWLINE
, which puts a newline at the end of the
buffer.
Formatting options are as follows:
Argument | Value | Meaning |
---|---|---|
|
|
perform no additional formatting. |
|
|
indent each line with a tab ( |
|
|
default - terminate buffer with a newline ( |
|
|
ignore |
Example
The following example code displays an error’s text, indented with a tab.
if ( e.Test() ) { StrBuf msg; e.Fmt( &msg, EF_INDENT ); printf( "ERROR:\n%s", msg.Text() ); }