Stefan,
If the cost function returns false or nans or inf, ceres assumes that the entire objective function evaluation has failed. This has different implications depending upon what stage of the algorithm you are in.
If you are at iteration zero and the evaluation of the cost and the jacobian fails, then the solver will terminate because the starting state of the solver cannot be relied upon.
during the trust region loop, we call evaluate twice. once to evaluate the cost of the candidate solution, if that fails, the candidate solution is treated as if it has infinite cost and the trust region loop runs again with a smaller trust region radius.
If the cost evaluation is successful and the step is deemed to be good and we move to it, we then evaluate the cost and the jacobian, and here if a failure occurs, we have reached a state which cannot be recovered from, therefore the solver terminates.
generally speaking, you can return false to implement a poor man's feasible region, and as long as you start with a feasible point, this will ensure that you remain in it.
Sameer