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

C/C++ API Documentation | 2025.1

# ClientUser::HandleError( Error * )

Process error data after a failed command.

Virtual? | Yes |
Class | `ClientUser` |
Arguments | `Error *e` | an `Error` object
Returns | `void` |

## Notes

The default implementation formats the error with `Error::Fmt()` and outputs the result with `OutputError()`.

2002.1 and newer servers do not call `HandleError()` to display errors. Instead, they call `Message()`. The default implementation of `Message()` calls `HandleError()` if its argument is a genuine error; as a result, older code that uses `HandleError()` can be used with the newer API and newer servers so long as the default implementation of `Message()` is retained.

## Example

`HandleError()` is called whenever a command encounters an error. For example:

    > p4 files nonexistent
    nonexistent - no such file(s).

In this case, the `Error` object given to `HandleError()` contains the text "nonexistent - no such file(s)." and has a severity of 2 (`E_WARN`).

To handle errors in a different way, create a subclass of `ClientUser` with an alternate implementation of `HandleError()`.

For example, if you want an audible warning on a fatal error, implement `HandleError()` as follows:

    void MyClientUser::HandleError( Error *err )
    {
        if ( err->IsFatal() ) printf ( "Fatal error!\n%c", 7 );
    }

Your search for returned results