Almost any MPI call returns an integer error code, which signifies the success of the operation. If no error occurs, the return code is MPI_SUCCESS:
if (MPI_Some_op(...) != MPI_SUCCESS)
{
// Process error
}
If an error occurs, MPI calls an error handler associated with the communicator, ...