Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2026.1

# Error::Fmt( StrBuf *, int )

Format the text of an error into a `StrBuf`, after applying formatting.

Virtual? | No |
Class | `Error` |
Arguments | `StrBuf *buf` | a pointer to the `StrBuf` to contain the formatted error
| `int opts` | formatting options
Returns | `void` |

## 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
--- | --- | ---
`EF_PLAIN` | `0x00` | perform no additional formatting.
`EF_INDENT` | `0x01` | indent each line with a tab (`\t`)
`EF_NEWLINE` | `0x02` | default - terminate buffer with a newline (`\n`)
`EF_NOXLATE` | `0x04` | ignore `P4LANGUAGE` setting

## 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() );
    }

Your search for returned results